This bugzilla service is closed. All entries have been migrated to
Bug 291 - Missing Aliasing assert or a bug
Summary: Missing Aliasing assert or a bug
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.0
Hardware: All All
: --- enhancement
Assignee: Nobody
Depends on:
Reported: 2011-06-09 15:50 UTC by Hordur Johannsson
Modified: 2019-12-04 10:50 UTC (History)
3 users (show)


Description Hordur Johannsson 2011-06-09 15:50:46 UTC
VectorXd a(2);
 a << 1,2;
 a = a.segment(0,1);
 cout << a;


using eval fixes the bug.

If this is the expected behaviour it would be useful to have an aliasing assert for this case.
Comment 1 Gael Guennebaud 2011-06-09 16:51:13 UTC
Detecting all cases of aliasing is a very difficult task. Though we do detect a few cases involving transpose, the programmer is supposed to know what he is doing.
Comment 2 Christoph Hertzberg 2011-06-09 21:20:10 UTC
Just a side note:
I guess this particular example could also be implemented using 

A general suggestion for this problem:
If a vector/matrix changes its size during assignment, one could:
* allocate a new (temp) vector
* assign the expression to the temp vector
* swap the vectors
* deallocate the temp vector (happens automatically)

I guess this would cause virtually no overhead in most cases, OTOH it might be a bad idea, if users rely on this behavior and then a vector accidentally does not change its size ...
Comment 3 Nobody 2019-12-04 10:50:54 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.