From d95521b4118c83b23997a823b0682a385609fd84 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 12 Dec 2014 21:05:35 +0000 Subject: [PATCH] re PR libstdc++/58594 (std::make_shared does not accept const types as parameters) PR libstdc++/58594 * include/bits/shared_ptr_base.h: Cast away cv-quals. * testsuite/20_util/shared_ptr/creation/58594-no-rtti.cc: New. * testsuite/20_util/shared_ptr/creation/private.cc: Make allocator rebindable so test passes with -fno-rtti. From-SVN: r218691 --- libstdc++-v3/ChangeLog | 6 +++++ libstdc++-v3/include/bits/shared_ptr_base.h | 2 +- .../shared_ptr/creation/58594-no-rtti.cc | 27 +++++++++++++++++++ .../20_util/shared_ptr/creation/private.cc | 12 +++++++-- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594-no-rtti.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7c3910362a3..a4ab4bfb5d4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -32,6 +32,12 @@ * libsupc++/vterminate.cc: Likewise. * src/c++11/thread.cc: Likewise. + PR libstdc++/58594 + * include/bits/shared_ptr_base.h: Cast away cv-quals. + * testsuite/20_util/shared_ptr/creation/58594-no-rtti.cc: New. + * testsuite/20_util/shared_ptr/creation/private.cc: Make allocator + rebindable so test passes with -fno-rtti. + 2014-12-12 Jonathan Wakely * include/bits/stl_iterator.h (make_reverse_iterator): LWG DR 2285. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 737a1a2553f..3ef783fa356 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1120,7 +1120,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_ptr(), _M_refcount() { typedef typename allocator_traits<_Alloc>::template - rebind_traits<_Tp> __traits; + rebind_traits::type> __traits; _Deleter __del = { __a }; auto __guard = std::__allocate_guarded(__del._M_alloc); _M_ptr = __guard.get(); diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594-no-rtti.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594-no-rtti.cc new file mode 100644 index 00000000000..2eb8b9542c1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594-no-rtti.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11 -fno-rtti" } +// { dg-do compile } + +// Copyright (C) 2014 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 +// 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 +// . + +#include + +// libstdc++/58594 +void test01() +{ + std::make_shared(); +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/private.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/private.cc index 46487bb27d4..63ab55524ef 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/private.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/private.cc @@ -37,8 +37,17 @@ public: }; template -struct MyAlloc : std::allocator +struct MyAlloc : std::allocator { + template + struct rebind { typedef MyAlloc other; }; + + MyAlloc() = default; + MyAlloc(const MyAlloc&) = default; + + template + MyAlloc(const MyAlloc&) { } + void construct(T* p) { ::new((void*)p) T(); } void destroy(T* p) { p->~T(); } }; @@ -49,4 +58,3 @@ int main() auto p = std::allocate_shared(a); return p->get(); } - -- 2.30.2