1
votes

When running my program I am currently retrieving the following Eigen assertion:

test_engine: /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:128: Eigen::internal::plain_array::plain_array() [with T = double; int Size = 16; int MatrixOrArrayOptions = 0]: Assertion `(reinterpret_cast(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.

The exact line of code which causes this assertion is:

  std::shared_ptr<Reference> ptr_tmp = std::make_shared<ReferenceLinCart>(cart_traj);

where Reference and ReferenceLinCart are defined in a common header file as:

  struct Reference {
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW
    virtual ~Reference() {}
  }

  struct ReferenceLinCart : Reference {
    Eigen::Transform<double, 3, Eigen::Affine> T_start;
    Eigen::Transform<double, 3, Eigen::Affine> T_goal;
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW
  };

The link in the description provided me with information concerning static size structure members, which is why I added the EIGEN_MAKE_ALIGNED_OPERATOR_NEW flag.

The g++ compile flags used are: -march=native -funroll-loops -std=c++11 -Ofast -Wall

Unfortunately I am still retrieving the same runtime assertion. Any suggestion on how to get rid of this?

1

1 Answers

1
votes

This is because make_shared does not honor requested alignement nor use operator new for allocation. You need to use allocate_shared with an aligned allocator (e.g., Eigen::aligned_Allocator).