diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 95b19b01f92..548a4ee88e3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2010-12-14 Jonathan Wakely + + PR libstdc++/46910 + * include/bits/shared_ptr_base.h (_Sp_counted_deleter): Do not + derive from _Sp_counted_ptr. + * testsuite/20_util/shared_ptr/cons/46910.cc: New. + * testsuite/20_util/shared_ptr/cons/43820.cc: Adjust. + * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust. + 2010-12-13 Rainer Orth * config/abi/post/solaris2.8/baseline_symbols.txt: Regenerate. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index da18147db5e..b3333576b28 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -318,7 +318,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Support for custom deleter and/or allocator template - class _Sp_counted_deleter : public _Sp_counted_ptr<_Ptr, _Lp> + class _Sp_counted_deleter : public _Sp_counted_base<_Lp> { typedef typename _Alloc::template rebind<_Sp_counted_deleter>::other _My_alloc_type; @@ -334,21 +334,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std) : _My_alloc_type(__a), _M_del(__d) { } }; - protected: - typedef _Sp_counted_ptr<_Ptr, _Lp> _Base_type; - public: // __d(__p) must not throw. _Sp_counted_deleter(_Ptr __p, _Deleter __d) - : _Base_type(__p), _M_del(__d, _Alloc()) { } + : _M_ptr(__p), _M_del(__d, _Alloc()) { } // __d(__p) must not throw. _Sp_counted_deleter(_Ptr __p, _Deleter __d, const _Alloc& __a) - : _Base_type(__p), _M_del(__d, __a) { } + : _M_ptr(__p), _M_del(__d, __a) { } virtual void _M_dispose() // nothrow - { _M_del._M_del(_Base_type::_M_ptr); } + { _M_del._M_del(_M_ptr); } virtual void _M_destroy() // nothrow @@ -369,6 +366,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } protected: + _Ptr _M_ptr; // copy constructor must not throw _My_Deleter _M_del; // copy constructor must not throw }; @@ -397,7 +395,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { void* __p = &_M_storage; ::new (__p) _Tp(); // might throw - _Base_type::_Base_type::_M_ptr = static_cast<_Tp*>(__p); + _Base_type::_M_ptr = static_cast<_Tp*>(__p); } template @@ -407,7 +405,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { void* __p = &_M_storage; ::new (__p) _Tp(std::forward<_Args>(__args)...); // might throw - _Base_type::_Base_type::_M_ptr = static_cast<_Tp*>(__p); + _Base_type::_M_ptr = static_cast<_Tp*>(__p); } // Override because the allocator needs to know the dynamic type diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc index 538126f694e..837c668efe9 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc @@ -32,9 +32,9 @@ void test01() { X* px = 0; std::shared_ptr p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 765 } + // { dg-error "incomplete" "" { target *-*-* } 763 } std::shared_ptr p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 857 } + // { dg-error "incomplete" "" { target *-*-* } 855 } } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc new file mode 100644 index 00000000000..d8275198c2e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation +// +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10.2 Class template shared_ptr [util.smartptr.shared] + +#include +#include + +// 20.9.10.2.1 shared_ptr constructors [util.smartptr.shared.const] + +struct deleter; + +class A +{ + ~A() = default; + friend struct deleter; +}; + +struct deleter +{ + void operator()(A* a) const; +}; + +void +test01() +{ + std::shared_ptr p(new A, deleter()); +} + diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc index c26b09dcec8..357e32f97e9 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -43,7 +43,7 @@ main() } // { dg-warning "note" "" { target *-*-* } 352 } -// { dg-warning "note" "" { target *-*-* } 1085 } +// { dg-warning "note" "" { target *-*-* } 1083 } // { dg-warning "note" "" { target *-*-* } 465 } // { dg-warning "note" "" { target *-*-* } 585 } // { dg-warning "note" "" { target *-*-* } 1048 }