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