I encountered a problem when I was using Eigen objects in my code. There is a class defined in my code:
class MyClass
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
MyClass();
/*other member functions*/
private:
float3 member_var;
Eigen::Matrix4f pose;
int id;
/*......*/
};
As the code is shown above, if pose
is not the first member variable in MyClass, e.g. after float3 member_var
, the program got segmentation fault ( core dumped) error.
If I put Eigen::Matrix4f pose
as the first member variable, there is no segfault error.
I checked the documentation of Eigen library about memory alignment issues, see here. It says that Eigen member variables are not required to be put at the beginning of the class.
I am wondering whether it is a bug from Eigen or my code?