This showed when trying to validate code via UBsan (-fsanitize=undefined) with llvm/clang sanitizers in a cmake project: Running 2 test cases... Connection to 127.0.0.1:1.337 Successfully connected to localhost:1.337 Connection to 127.0.0.1:1.337 Successfully connected to localhost:1.337 Connection to 127.0.0.1:1.337 Successfully connected to localhost:1.337 /usr/include/boost/endian/buffers.hpp:313:9: runtime error: store to misaligned address 0x7ffe7cfeade2 for type 'int', which requires 4 byte alignment 0x7ffe7cfeade2: note: pointer points here 00 00 01 40 fe 7c fe 7f 00 00 20 ae fe 7c fe 7f 00 00 10 ae fe 7c fe 7f 00 00 19 e3 5e 00 00 00 ^ SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/boost/endian/buffers.hpp:313:9 in
upstream patch can be found here: https://github.com/boostorg/endian/pull/22 is there a chance it can be added to the stable boost-1.65.0? I tested it locally and it's a valid fix for the bug.
In any case, I'm making it depend on boost-1.70.0 stabilization
the proposed user patch was declined, instead these two fixes are the official patches, so it seems. https://github.com/boostorg/endian/commit/e93f6a22703249f0ebfff25302147c64965d5907 https://github.com/boostorg/endian/commit/62802fee96f002134719d02158c6fe859847fd9b
Wow, I'm surprised the author of boost endian didn't know that unaligned access (even on platforms that support it), is still undefined behavior. While the patches are sound, I'd prefer to see this as an incentive to move to a stable boost 1.70.
I tried to backport it just for fun, but test case is too idiomatic for me, can't get my head around it. So yeah, it's best to go ahead for boost-1.70.0!
fixed by stable boost-1.71.0