diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 61c20a256657..3041e8738f3b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2013-10-02 Jonathan Wakely + + 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 * 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 fb19d0887dcb..f4bff77eabe1 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::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 000000000000..d1e3a7c5ddc1 --- /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 +// . + +#include + +// libstdc++/58594 +void test01() +{ + std::make_shared(); +}