Boost logo

Boost :

Subject: Re: [boost] clang-3.6 thread sanitizercomplainsonshared_ptroperations
From: Peter Dimov (lists_at_[hidden])
Date: 2015-01-24 14:35:58


Gaetano Mendola wrote:

> I tried tonight to see if the BOOST_SP_USE_STD_ATOMIC fixes the warning on
> my own real code but it doesn't.

...

> now defining BOOST_SP_USE_STD_ATOMIC:

...

> #2 boost::detail::sp_counted_base::destroy()
> /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:126
> (a.out+0x0000004ca97c)

It uses sp_counted_base_gcc_x86.hpp, so the define didn't take hold. What
probably happens is that you're using an older Boost version which doesn't
have the support for std::atomic, so the define doesn't work. The tests that
worked probably used a newer Boost.

You wrote earlier:

>>> I'm using clang 3.6 with boost 1.54

and sure enough, 1.54 didn't have BOOST_SP_USE_STD_ATOMIC:

https://github.com/boostorg/smart_ptr/blob/boost-1.54.0/include/boost/smart_ptr/detail/sp_counted_base.hpp

1.56 does:

https://github.com/boostorg/smart_ptr/blob/boost-1.56.0/include/boost/smart_ptr/detail/sp_counted_base.hpp

If you want to remain on 1.54, you can patch your sp_counted_base.hpp either
with the

#elif defined( BOOST_SP_USE_STD_ATOMIC )
# include <boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp>

part (adding of course sp_counted_base_std_atomic.hpp), or with the new
clang-specific version I referenced in my post:

https://github.com/boostorg/smart_ptr/commit/75de3dbcf1379119ee21a8029845c65fb8ce38a6


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk