[Boost-bugs] [Boost C++ Libraries] #7201: boost::make_shared clobbers libstdc++ std::thread

Subject: [Boost-bugs] [Boost C++ Libraries] #7201: boost::make_shared clobbers libstdc++ std::thread
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-07 04:00:09


#7201: boost::make_shared clobbers libstdc++ std::thread
--------------------------------+-------------------------------------------
 Reporter: t551@… | Owner: pdimov
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: smart_ptr
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: make_shared thread |
--------------------------------+-------------------------------------------
 This program fails to compile using g++ version 4.7.1.

 {{{
 #!cpp

 #include <functional>
 #include <thread>

 #include <boost/smart_ptr.hpp>

 void demo_entry(
     boost::shared_ptr<int> &demo_ptr
 )
 {
 }

 int main(int argc, char **argv)
 {
     auto demo_ptr = boost::make_shared<int>(5);

     std::thread demo_thread(
         demo_entry,
         std::ref(demo_ptr)
     );

     demo_thread.join();

     return 0;
 }

 }}}

 I get the following error output:

 {{{
 #!sh
 [100%] Building CXX object
 CMakeFiles/make_shared_repro.dir/make_shared_repro.cpp.o
 In file included from /home/ahmedtd/project/make-shared-
 repro/make_shared_repro.cpp:3:0:
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.1/include/g++-v4/thread: In
 instantiation of 'std::shared_ptr<std::thread::_Impl<_Callable> >
 std::thread::_M_make_routine(_Callable&&) [with _Callable =
 std::_Bind_simple<void (*(std::reference_wrapper<boost::shared_ptr<int>
>))(boost::shared_ptr<int>&)>]':
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.1/include/g++-v4/thread:133:9:
 required from 'std::thread::thread(_Callable&&, _Args&& ...) [with
 _Callable = void (&)(boost::shared_ptr<int>&); _Args =
 {std::reference_wrapper<boost::shared_ptr<int> >}]'
 /home/ahmedtd/project/make-shared-repro/make_shared_repro.cpp:20:5:
 required from here
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.1/include/g++-v4/thread:191:67:
 error: could not convert 'boost::make_shared(Arg1&&, Args&& ...) [with T =
 std::thread::_Impl<std::_Bind_simple<void
 (*(std::reference_wrapper<boost::shared_ptr<int>
>))(boost::shared_ptr<int>&)> >; Arg1 = std::_Bind_simple<void
 (*(std::reference_wrapper<boost::shared_ptr<int>
>))(boost::shared_ptr<int>&)>; Args = {}]()' from
 'boost::shared_ptr<std::thread::_Impl<std::_Bind_simple<void
 (*(std::reference_wrapper<boost::shared_ptr<int>
>))(boost::shared_ptr<int>&)> > >' to
 'std::shared_ptr<std::thread::_Impl<std::_Bind_simple<void
 (*(std::reference_wrapper<boost::shared_ptr<int>
>))(boost::shared_ptr<int>&)> > >'
 make[2]: *** [CMakeFiles/make_shared_repro.dir/make_shared_repro.cpp.o]
 Error 1
 make[1]: *** [CMakeFiles/make_shared_repro.dir/all] Error 2
 make: *** [all] Error 2
 }}}

 After deciphering the template error, it appears the problem stems from
 line 194 in the libstdc++ <thread> header, which has a non-namespace-
 qualified call to make_shared. For some reason, even though this code is
 declared in the `std` namespace, it is deciding to use boost::make_shared.

 This is particularly strange because at the point `<thread>` is processed
 by the compiler, no boost code has yet been included.

 I have no idea whether this is bug in boost::smart_ptr, libstdc++, or the
 compiler itself.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7201>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC