GCC Compiler Bug Causes Crashes
This bug is relevant for configurations which satisfy all of the following conditions:
- Using GCC >= 4.9 and < 6.0 to compile.
-O3compile flag. (This is default behavior for Release mode.)
c++14) compile flags.
The compiler sometimes generates SSE instructions (which require 16 byte alignment) using memory addresses that are not 16-byte-aligned. Since these errors lead to segfaults, suggesting that you tried to access invalid memory addresses, they are extremely hard to recognize and debug.
- Use GCC <= 4.8 or >= 6.0.
- Use clang to compile.
-O3 -march=<architecture>for an architecture that supports AVX. This way the compiler will generate AVX instead of SSE instructions which do allow unaligned memory access at a small performance penalty.
Also see the corresponding GCC bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66598