diff options
author | Jonathan Wakely <jwakely.gcc@gmail.com> | 2012-10-29 21:49:19 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2012-10-29 21:49:19 +0000 |
commit | 1ea58d3499b2362e735218eea1ca9f3f213534c4 (patch) | |
tree | a5167d0291a02c5e09e8f37ca3b9e4d292050dd5 | |
parent | 077d1abec135863c50dc0d7a11772b23aae22821 (diff) | |
download | gcc-1ea58d3499b2362e735218eea1ca9f3f213534c4.zip gcc-1ea58d3499b2362e735218eea1ca9f3f213534c4.tar.gz gcc-1ea58d3499b2362e735218eea1ca9f3f213534c4.tar.bz2 |
re PR libstdc++/55123 ([C++11] Construction of shared_ptr<const T> from unique_ptr<const T> fails)
PR libstdc++/55123
* include/bits/shared_ptr_base.h (__shared_count::_S_create_from_up):
Do not instantiate allocator with element_type.
* testsuite/20_util/shared_ptr/cons/55123.cc: New.
From-SVN: r192964
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/shared_ptr_base.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/shared_ptr/cons/55123.cc | 30 |
3 files changed, 39 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d60078a..52dad44 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2012-10-29 Jonathan Wakely <jwakely.gcc@gmail.com> + + PR libstdc++/55123 + * include/bits/shared_ptr_base.h (__shared_count::_S_create_from_up): + Do not instantiate allocator with element_type. + * testsuite/20_util/shared_ptr/cons/55123.cc: New. + 2012-10-28 Jonathan Wakely <jwakely.gcc@gmail.com> PR libstdc++/55041 diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 07ac000..e48a8fb 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -622,7 +622,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_create_from_up(std::unique_ptr<_Tp, _Del>&& __r, typename std::enable_if<!std::is_reference<_Del>::value>::type* = 0) { - return new _Sp_counted_deleter<_Tp*, _Del, std::allocator<_Tp>, + return new _Sp_counted_deleter<_Tp*, _Del, std::allocator<void>, _Lp>(__r.get(), __r.get_deleter()); } @@ -633,7 +633,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { typedef typename std::remove_reference<_Del>::type _Del1; typedef std::reference_wrapper<_Del1> _Del2; - return new _Sp_counted_deleter<_Tp*, _Del2, std::allocator<_Tp>, + return new _Sp_counted_deleter<_Tp*, _Del2, std::allocator<void>, _Lp>(__r.get(), std::ref(__r.get_deleter())); } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/55123.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/55123.cc new file mode 100644 index 0000000..35b517e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/55123.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012 Free Software Foundation +// +// 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++/55123 + +#include <memory> + +void f() { + std::unique_ptr<const int> y; + std::shared_ptr<const int> x = std::move(y); +} |