PR libstdc++/87278 restore support for std::make_shared<volatile T>()

Message ID 20180911115058.GA22225@redhat.com
State New
Headers show
Series
  • PR libstdc++/87278 restore support for std::make_shared<volatile T>()
Related show

Commit Message

Jonathan Wakely Sept. 11, 2018, 11:50 a.m.
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.

Tested x86_64-linux, committed to trunk and gcc-8-branch.
commit 29eed23367a6a01a5fb60d7e88a49f3470cb3915
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Sep 11 12:16:08 2018 +0100

    PR libstdc++/87278 restore support for std::make_shared<volatile T>()
    
            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.

Patch

diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index 2a82f186328..d7b044b83cd 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -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
index 00000000000..04ab36734d2
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/87278.cc
@@ -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>();
+}