#9207 closed Bugs (invalid)
different sizeof atomic_count (boost/asio/detail/atomic_count.hpp) type after comilation with --std=c++11 than after comilation without --std=c++11 (gcc, x86_64).
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | Cc: |
Description
atomic_count has different size when compiling with --std==c++11 (sizeof(long)) than compiling without --std=c++11 (sizof(int)). Hence classes which use atomic_count have different memory layout of members depending on --std compilation option. This leads to troubles when program is built from object files compiled with --std=c++11 and files compiled without --std=c++11.
This phenomena is not visible for clang (clang std lib contains std::atomic) Problem is also not visible on i386 (sizeof(long) == sizeof(int))
Problem exists in 1.54 and on the trunk.
In attached example task_io_service has different size in two compilation units. This leads to segmentation fault.
Attachments (1)
Change History (3)
by , 9 years ago
Attachment: | test.tar.gz added |
---|
comment:1 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Don't mix and match language versions. Or if you really really must, define BOOST_ASIO_DISABLE_STD_ATOMIC.
comment:2 by , 7 years ago
The assertion that the phenomena is not visible if using clang is incorrect. The test program would crash on OS/X (10.10.4) with brew installed Boost 1.58.0, too.
Clang version:
mac: clang --version Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix
program with segmentation fault due to different size of atomic_count in task_io_service class