aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely.gcc@gmail.com>2013-10-02 19:55:14 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2013-10-02 20:55:14 +0100
commit3fd113d7f105df5d70be50630c40ce65e82d3c34 (patch)
treeda158cd3e611e74a0e7df18b51dc0da8d00d73c3 /libstdc++-v3
parentbbc02b69b56dd2bd008464ef5529c39c9bdb8622 (diff)
downloadgcc-3fd113d7f105df5d70be50630c40ce65e82d3c34.zip
gcc-3fd113d7f105df5d70be50630c40ce65e82d3c34.tar.gz
gcc-3fd113d7f105df5d70be50630c40ce65e82d3c34.tar.bz2
re PR libstdc++/58594 (std::make_shared does not accept const types as parameters)
PR libstdc++/58594 * include/bits/shared_ptr_base.h (_Sp_counted_ptr_inplace::_M_get_deleter()): Cast away cv-quals. * testsuite/20_util/shared_ptr/creation/58594.cc: New. From-SVN: r203131
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h6
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594.cc27
3 files changed, 37 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 61c20a2..3041e87 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2013-10-02 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ PR libstdc++/58594
+ * include/bits/shared_ptr_base.h
+ (_Sp_counted_ptr_inplace::_M_get_deleter()): Cast away cv-quals.
+ * testsuite/20_util/shared_ptr/creation/58594.cc: New.
+
2013-10-02 Tim Shen <timshen91@gmail.com>
* include/bits/regex_compiler.h
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index fb19d08..f4bff77 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -459,10 +459,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_get_deleter(const std::type_info& __ti) noexcept
{
#ifdef __GXX_RTTI
- return __ti == typeid(_Sp_make_shared_tag) ? _M_ptr() : nullptr;
-#else
- return nullptr;
+ if (__ti == typeid(_Sp_make_shared_tag))
+ return const_cast<typename remove_cv<_Tp>::type*>(_M_ptr());
#endif
+ return nullptr;
}
private:
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594.cc
new file mode 100644
index 0000000..d1e3a7c
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594.cc
@@ -0,0 +1,27 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2013 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/>.
+
+#include <memory>
+
+// libstdc++/58594
+void test01()
+{
+ std::make_shared<const int>();
+}