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
This commit is contained in:
Jonathan Wakely 2013-10-02 19:55:14 +00:00 committed by Jonathan Wakely
parent bbc02b69b5
commit 3fd113d7f1
3 changed files with 37 additions and 3 deletions

View File

@ -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

View File

@ -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:

View File

@ -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>();
}