Opened 7 years ago
Closed 7 years ago
#11832 closed Bugs (fixed)
clang-cl + boost intrusive = miscompile
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | To Be Determined | Component: | intrusive |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I'm not sure what the problem source is, but boost intrusive examples fail when compiled with clang-cl (but pass with clang targetting mingw).
Attached is a reduced example doc_how_to_use.cpp and a batch file running it under clang(mingw), cl, clang-cl. The two reported address should be the identical per the original example which compares them. Yet, clang-cl (last) prints different addresses:
clang++ (i686,mingw) values=0x3519d0 memberlist = 0x3519d0 cl doc_how_to_use.cpp values=003D96D0 memberlist = 003D96D0 clang-cl values=005196D0 memberlist = 005196D1
clang version 3.8.0 (trunk 253440).
Attachments (3)
Change History (5)
by , 7 years ago
by , 7 years ago
by , 7 years ago
Attachment: | doc_how_to_use.cpp added |
---|
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Many thanks for the report and the solution. Fixed in:
https://github.com/boostorg/intrusive/commit/72976d34f6694ad6a7f29aa39d3128f98d8ddd42
Reid Kleckner diagnosed the problem in https://llvm.org/bugs/show_bug.cgi?id=25761:
In boost/intrusive/detail/parent_from_member.hpp, the implementation of offset_from_pointer_to_member goes down the #idefs to the #else case, which subtracts one from the offset to create the off-by-one pointer. BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER should be defined for clang-cl.
This could be fixed by modifying parent_from_member.hpp:26 from:
to:
since BOOST_MSVC is defined only for Visual C++ while _MSC_VER is defined for both Visual C++ and clang-cl.