* [v3] fix libstdc++/46910
@ 2010-12-14 23:32 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2010-12-14 23:32 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 419 bytes --]
2010-12-14 Jonathan Wakely <jwakely.gcc@gmail.com>
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.
tested x86_64-linux, committed to trunk
[-- Attachment #2: 46910.txt --]
[-- Type: text/plain, Size: 4929 bytes --]
Index: include/bits/shared_ptr_base.h
===================================================================
--- include/bits/shared_ptr_base.h (revision 167789)
+++ include/bits/shared_ptr_base.h (working copy)
@@ -318,7 +318,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Support for custom deleter and/or allocator
template<typename _Ptr, typename _Deleter, typename _Alloc, _Lock_policy _Lp>
- 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<typename... _Args>
@@ -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
Index: testsuite/20_util/shared_ptr/cons/46910.cc
===================================================================
--- testsuite/20_util/shared_ptr/cons/46910.cc (revision 0)
+++ testsuite/20_util/shared_ptr/cons/46910.cc (revision 0)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10.2 Class template shared_ptr [util.smartptr.shared]
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// 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<A> p(new A, deleter());
+}
+
Index: testsuite/20_util/shared_ptr/cons/43820.cc
===================================================================
--- testsuite/20_util/shared_ptr/cons/43820.cc (revision 167789)
+++ testsuite/20_util/shared_ptr/cons/43820.cc (working copy)
@@ -32,9 +32,9 @@ void test01()
{
X* px = 0;
std::shared_ptr<X> p1(px); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 765 }
+ // { dg-error "incomplete" "" { target *-*-* } 763 }
std::shared_ptr<X> p9(ap()); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 857 }
+ // { dg-error "incomplete" "" { target *-*-* } 855 }
}
Index: testsuite/20_util/weak_ptr/comparison/cmp_neg.cc
===================================================================
--- testsuite/20_util/weak_ptr/comparison/cmp_neg.cc (revision 167789)
+++ testsuite/20_util/weak_ptr/comparison/cmp_neg.cc (working copy)
@@ -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 }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-14 22:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-14 23:32 [v3] fix libstdc++/46910 Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).