[eigen] Fixed-size vectorizable members and std::make_shared

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


Hi,

I just ran into a subtle bug, the solution of which doesn't seem to be documented anywhere. If I have a class with a fixed-size, vectorizable member, even having defined EIGEN_MAKE_ALIGNED_OPERATOR_NEW, creating a shared pointer to it using

    std::shared_ptr<MyClass> x = std::make_shared<MyClass>(42);

succeeds, but any access to the member crashes. The solution is to use allocate_shared:

    std::shared_ptr<MyClass> x = std::allocate_shared<MyClass>(Eigen::aligned_allocator<MyClass>(), 42);

Is there a way to put an assertion in some constructor, maybe in that of DenseStorage, to check that (this % 16 ==0)? It took me quite some time to hunt down this bug...

M.



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