// Base class (with not copy-pasted robot-specific methods) class A : public Eigen::Matrix<double, 6, 1> { public: // Copy constructor from any Eigen matrix type template<typename OtherDerived> A(const Eigen::MatrixBase<OtherDerived>& other) : BaseClass(other) {}
// Reuse assignment operators from base class using BaseClass::operator=;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW };
// Derived class type, which will hold additional methods class B : public A { public: template<typename OtherDerived> B(const Eigen::MatrixBase<OtherDerived>& other) : Ft_v_vector(other) {}
EIGEN_MAKE_ALIGNED_OPERATOR_NEW };
When I run this code on Linux - it works just fine. When I run this on QNX - it fails with Unalligned Array Assert. The backtrace is here:
#0 0xb033dad1 in SignalKill () from /usr/qnx641/target/qnx6/x86/lib/libc.so.3 #1 0xb032c82e in raise () from /usr/qnx641/target/qnx6/x86/lib/libc.so.3 #2 0xb032ab08 in abort () from /usr/qnx641/target/qnx6/x86/lib/libc.so.3 #3 0xb032ad29 in __assert () from /usr/qnx641/target/qnx6/x86/lib/libc.so.3 #4 0x080534ec in ei_matrix_array (this=0x7f42db4) at /opt/qnx641/target/qnx6/mrlib/include/eigen2/Eigen/src/Core/MatrixStorage.h:43 #5 0x0805350f in ei_matrix_storage (this=0x7f42db4) at /opt/qnx641/target/qnx6/mrlib/include/eigen2/Eigen/src/Core/MatrixStorage.h:79 #6 0x0809936f in Matrix<Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<double>, Eigen::Matrix<double, 6, 1, 2, 6, 1> > > ( this=0x7f42db4, other=@0x7f42ccc) at /opt/qnx641/target/qnx6/mrlib/include/eigen2/Eigen/src/Core/Matrix.h:405 #7 0x080981a4 in A (this=0x7f42db4) at mrmath/ft_v_vector.cc:28 #8 0x0809820f in B (this=0x7f42db4) at mrmath/ft_v_vector.cc:185 #9 0x08078293 in mrrocpp::edp::common::manip_effector::compute_servo_joints_and_frame (this=0x80d7fc0) at edp_e_manip.cc:55
The code, that causes the abort is just creating local, temporary variable of class B: B servo_real_kartez_pos;
I have checked, that QNX compiler honours EIGEN_ALIGN_128 statement (I am 100% sure,
checked with gdb for very simple structure alignment with and without this statement).
The question is - where is my mistake? Is it correct to make inherit in the above way? The problem seems to be, that in frames #8 to #4 "this" is not aligned to 128bit boundary.
I have tried adding EIGEN_ALIGN_128 and virtual inheritance, but this did not solve the problem.