This bugzilla service is closed. All entries have been migrated to
Bug 1012 - Map<>.noalias() = A * B triggers memory allocation
Summary: Map<>.noalias() = A * B triggers memory allocation
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - expression templates (show other bugs)
Version: 3.2
Hardware: All Other UNIX-like
: Normal Wrong Result
Assignee: Nobody
Depends on:
Reported: 2015-05-06 04:04 UTC by Chris Dyer
Modified: 2019-12-04 14:36 UTC (History)
3 users (show)


Description Chris Dyer 2015-05-06 04:04:34 UTC
It seems that noalias() doesn't behave properly with Map<>ed matrices. (However, while this is broken in the current release -- 3.2.4 -- it appears to have been corrected in the development repository, so I'm working around it by using this.)

Here is some repro code:

#include <Eigen/Eigen>
#include <cstdlib>

int main() {
  using namespace Eigen;
  float* a = (float*)malloc(10 * 10 * sizeof(float));
  float* b = (float*)malloc(10 * 10 * sizeof(float));
  float* c = (float*)malloc(10 * 10 * sizeof(float));
  Map<MatrixXf> ma(a, 10, 10);
  Map<MatrixXf> mb(b, 10, 10);
  Map<MatrixXf> mc(c, 10, 10);
  mc.noalias() = ma * mb;    // fails with 3.2.4, succeeds with dev
  mc.noalias() += ma * mb;   // fails with 3.2.4, succeeds with dev

Here is my compiler info:
$ g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
Comment 1 Christoph Hertzberg 2015-05-06 11:30:45 UTC
This appears to be a duplicate of Bug 729. I manually backported the fix here:
Comment 2 Nobody 2019-12-04 14:36:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.