Here's a minimalistic example: #include <memory> struct A : std::enable_shared_from_this< A > {}; int main() { std::make_shared< A >()->shared_from_this(); } It throws a bad_weak_ptr exception, which is AFAICT wrong.
*** Bug 36950 has been marked as a duplicate of this bug. ***
Jonathan, can you have a look? If you can confirm the issue, is it just matter of adding a call to __enable_shared_from_this_helper(_M_refcount, _M_ptr, _M_ptr) to __shared_ptr(_Sp_make_shared_tag, _Alloc, _Args&&...) ?? PS: I'm going to adjust some arguments around from _Alloc to const _Alloc&...
(In reply to comment #2) > Jonathan, can you have a look? If you can confirm the issue, is it just matter > of adding a call to __enable_shared_from_this_helper(_M_refcount, _M_ptr, > _M_ptr) to __shared_ptr(_Sp_make_shared_tag, _Alloc, _Args&&...) ?? Yes, that's the right fix. > PS: I'm going to adjust some arguments around from _Alloc to const _Alloc&... Cool. Thanks for catching this, Daniel.
Thanks, fix forthcoming.
Subject: Bug 36949 Author: paolo Date: Mon Jul 28 23:28:16 2008 New Revision: 138219 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138219 Log: 2008-07-28 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/36949 * include/tr1_impl/boost_shared_ptr.h (__shared_ptr(_Sp_make_shared_tag, _Alloc, _Args&&...): Call __enable_shared_from_this_helper. * testsuite/20_util/shared_ptr/creation/36949.cc: New. Added: trunk/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/tr1_impl/boost_shared_ptr.h
Fixed.