Print warning if incompatible alignment option chosen #6184
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Users repeatedly report segmentation faults coming from Memory.h in the Eigen code (aligned_free/handmade_aligned_free). This is because PCL uses Eigen's handmade_aligned_malloc but user code does not use the corresponding handmade_aligned_free (or the other way around), due to chosen SSE/AVX flags and the resulting alignment requirements. PCL's CMake config handles this by automatically setting SSE/AVX options in the user project as they are used in PCL, but not everyone uses CMake. This commit adds a check within PCL's header files for this kind of incompatibility.
At first I considered solving theses incompatibilities automatically by setting EIGEN_MALLOC_ALREADY_ALIGNED and EIGEN_MAX_ALIGN_BYTES, but that would have been more complex and error-prone, so I decided only for checking and warning.
I would have preferred
#warning
which however is not available on MSVC.#pragma message
is an option on MSVC, but this is too easily overlooked IMO. Users have the option to silence this by defining thePCL_SILENCE_MALLOC_WARNING
macro (in case of false positive).