Bug 369 - Improperly aligned Quaternion class
Improperly aligned Quaternion class
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Geometry
3.0
All Windows
: --- major
Assigned To: Nobody
:
: 378 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-27 14:42 UTC by fsck
Modified: 2011-11-20 07:24 UTC (History)
4 users (show)



Attachments

Description fsck 2011-10-27 14:42:51 UTC
There appears to be a problem with the alignment of the Eigen::Quaternion class. The problem is that the EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT assertion is raised if a Quaternion is allocated on the heap.

Configuration: Microsoft Visual Studio 2010 Express, SSE2 architecture enabled, Eigen vectorization enabled, 32-bit build.

The problem in is produced with the following code:

return new Eigen::Quaternion< float >( a, b, c, d ); // where a,b,c,d are arbitrary values

And is caused by the regular (unaligned) new allocator being called, instead of the aligned allocator (as overloaded by EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF), and the fact that the Quaterion class apparently requires an aligned member:

Coefficients m_coeffs;

Because the unaligned allocator is called, this requirement is not met and an assertion is thrown.

The problem seens to be fixed by overloading the new operator in the Quaternion class (this may not be the best place, but it works) by adding the following to the Quaternion class (copied from Matrix):

enum { NeedsToAlign = (!(_Options&DontAlign)) };
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
Comment 1 Benoit Jacob 2011-10-31 14:25:36 UTC
Fixed in fad437303568. The problem was actually a bit worse than that. Thanks for the report.
Comment 2 Benoit Jacob 2011-10-31 15:49:06 UTC
pushed to 3.0 branch: f78e89cc992e
Comment 3 Benoit Jacob 2011-11-20 07:24:44 UTC
*** Bug 378 has been marked as a duplicate of this bug. ***

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