New user self-registration is disabled due to spam. Please email eigen-core-team @ if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
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: 2011-06-09 21:20 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 ...

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