Opened 7 years ago

Closed 7 years ago

#11832 closed Bugs (fixed)

clang-cl + boost intrusive = miscompile

Reported by: Yaron Keren <yaron.keren@…> 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)

doc.bat (464 bytes ) - added by Yaron Keren <yaron.keren@…> 7 years ago.
doc.2.bat (464 bytes ) - added by Yaron Keren <yaron.keren@…> 7 years ago.
doc_how_to_use.cpp (706 bytes ) - added by Yaron Keren <yaron.keren@…> 7 years ago.

Download all attachments as: .zip

Change History (5)

by Yaron Keren <yaron.keren@…>, 7 years ago

Attachment: doc.bat added

by Yaron Keren <yaron.keren@…>, 7 years ago

Attachment: doc.2.bat added

by Yaron Keren <yaron.keren@…>, 7 years ago

Attachment: doc_how_to_use.cpp added

comment:1 by Yaron Keren <yaron.keren@…>, 7 years ago

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:

#if defined(BOOST_MSVC) || ((defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && defined(BOOST_INTEL))

to:

#if defined(_MSC_VER) || ((defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && defined(BOOST_INTEL))

since BOOST_MSVC is defined only for Visual C++ while _MSC_VER is defined for both Visual C++ and clang-cl.

comment:2 by Ion Gaztañaga, 7 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.