]> code.ossystems Code Review - openembedded-core.git/blob
177afa2ce7bdfc7bd246fe28fd870d867c652097
[openembedded-core.git] /
1 Upstream-Status: Inappropriate [Backport]
2 From 1934cdd502a4bad6e1c54c4206b9361909f01083 Mon Sep 17 00:00:00 2001
3 From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Sun, 17 Apr 2011 21:46:20 +0000
5 Subject: [PATCH 134/200] 2011-04-17  Daniel Krugler  <daniel.kruegler@googlemail.com>
6             Paolo Carlini  <paolo.carlini@oracle.com>
7
8         PR libstdc++/48635 (again)
9         * include/bits/unique_ptr.h (unique_ptr<>::unique_ptr(unique_ptr<>&&),
10         unique_ptr<_Tp[]>::unique_ptr(unique_ptr<>&&),
11         unique_ptr<>::operator=(unique_ptr<>&&),
12         unique_ptr<_Tp[]>::operator=(unique_ptr<>&&)): Use forward<_Ep>, not
13         forward<_Dp>, to forward the deleter.
14         * testsuite/20_util/unique_ptr/assign/48635_neg.cc: New.
15
16
17 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172620 138bc75d-0d04-0410-961f-82ee72b054a4
18
19 index 9ab1938..9d5d206 100644
20 --- a/libstdc++-v3/include/bits/unique_ptr.h
21 +++ b/libstdc++-v3/include/bits/unique_ptr.h
22 @@ -153,7 +153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
23                    && std::is_convertible<_Ep, _Dp>::value))>
24              ::type>
25         unique_ptr(unique_ptr<_Up, _Ep>&& __u)
26 -       : _M_t(__u.release(), std::forward<deleter_type>(__u.get_deleter()))
27 +       : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
28         { }
29  
30  #if _GLIBCXX_USE_DEPRECATED
31 @@ -186,7 +186,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
32         operator=(unique_ptr<_Up, _Ep>&& __u)
33         {
34           reset(__u.release());
35 -         get_deleter() = std::forward<deleter_type>(__u.get_deleter());
36 +         get_deleter() = std::forward<_Ep>(__u.get_deleter());
37           return *this;
38         }
39  
40 @@ -306,7 +306,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
41  
42        template<typename _Up, typename _Ep>
43         unique_ptr(unique_ptr<_Up, _Ep>&& __u)
44 -       : _M_t(__u.release(), std::forward<deleter_type>(__u.get_deleter()))
45 +       : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
46         { }
47  
48        // Destructor.
49 @@ -326,7 +326,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
50         operator=(unique_ptr<_Up, _Ep>&& __u)
51         {
52           reset(__u.release());
53 -         get_deleter() = std::forward<deleter_type>(__u.get_deleter());
54 +         get_deleter() = std::forward<_Ep>(__u.get_deleter());
55           return *this;
56         }
57  
58 diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc
59 new file mode 100644
60 index 0000000..1ed53ee
61 --- /dev/null
62 +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc
63 @@ -0,0 +1,50 @@
64 +// { dg-options "-std=gnu++0x" }
65 +// { dg-do compile }
66 +
67 +// Copyright (C) 2011 Free Software Foundation
68 +//
69 +// This file is part of the GNU ISO C++ Library.  This library is free
70 +// software; you can redistribute it and/or modify it under the
71 +// terms of the GNU General Public License as published by the
72 +// Free Software Foundation; either version 3, or (at your option)
73 +// any later version.
74 +
75 +// This library is distributed in the hope that it will be useful,
76 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
77 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
78 +// GNU General Public License for more details.
79 +
80 +// You should have received a copy of the GNU General Public License
81 +// along with this library; see the file COPYING3.  If not see
82 +// <http://www.gnu.org/licenses/>.
83 +
84 +#include <memory>
85 +
86 +struct D;
87 +
88 +struct B
89 +{
90 + B& operator=(D&) = delete; // { dg-error "declared here" }
91 +
92 + template<class T>
93 +   void operator()(T*) const {}
94 +};
95 +
96 +struct D : B { };
97 +
98 +// libstdc++/48635
99 +void f()
100 +{
101 +  B b;
102 +  D d;
103 +
104 +  std::unique_ptr<int, B&> ub(nullptr, b);
105 +  std::unique_ptr<int, D&> ud(nullptr, d);
106 +  ub = std::move(ud);
107 +// { dg-error "use of deleted function" "" { target *-*-* } 189 }
108 +
109 +  std::unique_ptr<int[], B&> uba(nullptr, b);
110 +  std::unique_ptr<int[], D&> uda(nullptr, d);
111 +  uba = std::move(uda);
112 +// { dg-error "use of deleted function" "" { target *-*-* } 329 }
113 +}
114 -- 
115 1.7.0.4
116