diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ab9183c4115..25f0d56f864 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2008-07-28 Paolo Carlini + + 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. + 2008-07-24 Paolo Carlini PR libstdc++/36924 diff --git a/libstdc++-v3/include/tr1_impl/boost_shared_ptr.h b/libstdc++-v3/include/tr1_impl/boost_shared_ptr.h index a3fd80e8551..5da40516bd6 100644 --- a/libstdc++-v3/include/tr1_impl/boost_shared_ptr.h +++ b/libstdc++-v3/include/tr1_impl/boost_shared_ptr.h @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -505,13 +505,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 // This constructor is non-standard, it is used by allocate_shared. template __shared_ptr(_Sp_make_shared_tag __tag, _Alloc __a, _Args&&... __args) - : _M_ptr() - , _M_refcount(__tag, (_Tp*)0, __a, std::forward<_Args>(__args)...) + : _M_ptr(), _M_refcount(__tag, (_Tp*)0, __a, + std::forward<_Args>(__args)...) { // _M_ptr needs to point to the newly constructed object. // This relies on _Sp_counted_ptr_inplace::_M_get_deleter. - void * __p = _M_refcount._M_get_deleter(typeid(__tag)); + void* __p = _M_refcount._M_get_deleter(typeid(__tag)); _M_ptr = static_cast<_Tp*>(__p); + __enable_shared_from_this_helper(_M_refcount, _M_ptr, _M_ptr); } template + +struct A : std::enable_shared_from_this { }; + +// libstdc++/36949 +void test01() +{ + std::make_shared()->shared_from_this(); +} + +int main() +{ + test01(); + return 0; +}