PR libstdc++/87278 restore support for std::make_shared<volatile T>()
authorJonathan Wakely <jwakely@redhat.com>
Tue, 11 Sep 2018 11:50:39 +0000 (12:50 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 11 Sep 2018 11:50:39 +0000 (12:50 +0100)
PR libstdc++/87278
* include/bits/shared_ptr.h (make_shared): Use remove_cv instead of
remove_const.
* testsuite/20_util/shared_ptr/creation/87278.cc: New test.

From-SVN: r264207

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/shared_ptr.h
libstdc++-v3/testsuite/20_util/shared_ptr/creation/87278.cc [new file with mode: 0644]

index 1a1a535532e8581c3ba23a1db08ea5030c0f97fd..b23dfe47d1979dc8c2b499f38d2c05edeccc5ca9 100644 (file)
@@ -1,5 +1,10 @@
 2018-09-11  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/87278
+       * include/bits/shared_ptr.h (make_shared): Use remove_cv instead of
+       remove_const.
+       * testsuite/20_util/shared_ptr/creation/87278.cc: New test.
+
        Implement LWG 2905 changes to constrain unique_ptr constructors
        * include/bits/unique_ptr.h (__uniq_ptr_impl): Add assertions to
        check deleter type.
index 2a82f18632840d89f362b998c2ebfe7bc4f6061f..d7b044b83cdf8ac2934f51515b3f659499941c79 100644 (file)
@@ -714,7 +714,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline shared_ptr<_Tp>
     make_shared(_Args&&... __args)
     {
-      typedef typename std::remove_const<_Tp>::type _Tp_nc;
+      typedef typename std::remove_cv<_Tp>::type _Tp_nc;
       return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(),
                                       std::forward<_Args>(__args)...);
     }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/87278.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/87278.cc
new file mode 100644 (file)
index 0000000..04ab367
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (C) 2018 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <memory>
+
+void
+test01()
+{
+  std::make_shared<volatile int>();
+}