Re: [eigen] Eigen 2 alignment errors in VS2010

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


This is well-known to us :-), your analysis is correct, and the fix is to use the std::vector specialization that we provide, its resize() method doesn't get a value_type passed by value. Read this:
http://eigen.tuxfamily.org/dox/StlContainers.html

Benoit

2010/8/17 <lfrfly@xxxxxxxxxxx>
I am attempting to create a struct

struct Triangle
{
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
  Eigen::Vector2d verts[3];
};

and then to create a vector of triangles:

vector<Triangle> tris(20);

However, this is causing the following compile error under Visual Studio 2010:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(870): error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned
There is no error under g++ 4.5.0.

As far as I can tell, this occurs because a Triangle is passed to the vector's resize() function by value, and you can't make any promises about the alignment of function parameters passed by value apparently.

Is there any kind of workaround for this issue?





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/