The Eigen documentation mentions that structures having fixed-size vectorizable Eigen types can cause problems with allocation. They mention:
If you're compiling in [c 17] mode only with a sufficiently recent compiler (e.g., GCC>=7, clang>=5, MSVC>=19.12), then everything is taken care by the compiler and you can stop reading.
Does it mean that the problem is present when compiling with [c 20], since they stress [c 17] mode only? Or is the problem solved for any compiler since [c 17]?
CodePudding user response:
This statement is based on P0035R4 (Dynamic memory allocation for over-aligned data) which was introduced in C 17, which means the statement arguably holds also for C 20. However, there seem to be some issues and pitfalls with this statement, even if following the advice of the Eigen guidelines, e.g. as highlighted in PointCloudLibrary / pcl / issue #4258.
CodePudding user response:
The documentation is pretty clear: only compiling in c 17
mode with a recent compiler (it's an AND) protects you from the alignment issues. So, using a more recent compiler but failing to set -std=c 17
exposes you to the issue. The solution, as suggested in the documentation, is to modify the code and take advantage of the EIGEN_MAKE_ALIGNED_OPERATOR_NEW
macro (which is empty for c 17
)
Alternatively, the documentation proposes other, less intrusive solutions: here.