Re: [eigen] Structures having Eigen members and make_shared |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Hi Herve,
I was just reading up on the Eigen docs under Cause 2,
The same issue will be exhibited by any classes/functions by-passing operator new to allocate memory, that is, by performing custom memory allocation followed by calls to the placement new operator. This is for instance typically the case ofstd::make_shared
orstd::allocate_shared
for which is the solution is to use an aligned allocator as detailed in the solution for STL containers.
If you use the Eigen::aligned_allocator does it resolve the assertion, (e.g. make_shared<MyStruct, Eigen::aligned_allocator<MyStruct>>)?
(You have my sympathies in struggling with alignment issues. :} )
-Mark
On Wed, Jun 22, 2016 at 6:55 PM, Hervé Audren <h.audren@xxxxxxxxxx> wrote:
Hello,
We recently ran into a "bug" where we had a structure containing Eigen members that triggered the infamous "unaligned array" assertion. Unfortunately, the solution proposed by the Eigen documentation is to addEIGEN_MAKE_ALIGNED_OPERATOR_NEW somewhere in the code, but it does not have any effect on make_shared<MyStruct>(args).
As I understand it, Eigen will try to keep C++03 compatibility as much as possible, and I am not sure it is possible to support this C++11 feature without breaking that. Maybe the documentation could be updated ?
Note: a simple fix is to use the slightly less efficient:
my_ptr = std::shared_ptr<MyStruct>(new MyStruct).
Cheers,
Hervé
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |