]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
beb1ef86a2426724e1ae6373f55622940c47a6c4
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 Upstream-Status: Inappropriate [Backport]
2 From 2ce87b6b9c9143a22381eec77bbf1fd7016e132d Mon Sep 17 00:00:00 2001
3 From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Sat, 16 Apr 2011 00:55:53 +0000
5 Subject: [PATCH 129/200] 2011-04-15 Daniel Krugler <daniel.kruegler@googlemail.com>
6 Paolo Carlini <paolo.carlini@oracle.com>
7
8 PR libstdc++/48635
9 * include/bits/unique_ptr.h (unique_ptr<>::operator=(unique_ptr&&),
10 unique_ptr<>::operator=(unique_ptr<>&&),
11 unique_ptr<_Tp[],>::operator=(unique_ptr&&),
12 unique_ptr<_Tp[],>::operator=(unique_ptr<>&&)): Forward the deleter
13 instead of moving it.
14 * testsuite/20_util/unique_ptr/assign/48635.cc: New.
15
16
17 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172533 138bc75d-0d04-0410-961f-82ee72b054a4
18
19 index 5df4325..1be2e7a 100644
20 --- a/libstdc++-v3/include/bits/unique_ptr.h
21 +++ b/libstdc++-v3/include/bits/unique_ptr.h
22 @@ -171,7 +171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
23 operator=(unique_ptr&& __u)
24 {
25 reset(__u.release());
26 - get_deleter() = std::move(__u.get_deleter());
27 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
28 return *this;
29 }
30
31 @@ -184,7 +184,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
32 operator=(unique_ptr<_Up, _Ep>&& __u)
33 {
34 reset(__u.release());
35 - get_deleter() = std::move(__u.get_deleter());
36 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
37 return *this;
38 }
39
40 @@ -315,7 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
41 operator=(unique_ptr&& __u)
42 {
43 reset(__u.release());
44 - get_deleter() = std::move(__u.get_deleter());
45 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
46 return *this;
47 }
48
49 @@ -324,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 operator=(unique_ptr<_Up, _Ep>&& __u)
51 {
52 reset(__u.release());
53 - get_deleter() = std::move(__u.get_deleter());
54 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
55 return *this;
56 }
57
58 diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
59 new file mode 100644
60 index 0000000..99b412b
61 --- /dev/null
62 +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
63 @@ -0,0 +1,78 @@
64 +// { dg-options "-std=gnu++0x" }
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 along
80 +// with this library; see the file COPYING3. If not see
81 +// <http://www.gnu.org/licenses/>.
82 +
83 +#include <memory>
84 +#include <testsuite_hooks.h>
85 +
86 +struct Deleter
87 +{
88 + Deleter() = default;
89 + Deleter(const Deleter&) = default;
90 + Deleter(Deleter&&) = default;
91 +
92 + Deleter&
93 + operator=(const Deleter&)
94 + {
95 + bool test __attribute__((unused)) = true;
96 + VERIFY( true );
97 + return *this;
98 + }
99 +
100 + Deleter&
101 + operator=(Deleter&&)
102 + {
103 + bool test __attribute__((unused)) = true;
104 + VERIFY( false );
105 + return *this;
106 + }
107 +
108 + template<class T>
109 + void
110 + operator()(T*) const { }
111 +};
112 +
113 +struct DDeleter : Deleter { };
114 +
115 +// libstdc++/48635
116 +void test01()
117 +{
118 + Deleter d;
119 +
120 + std::unique_ptr<int, Deleter&> p1(nullptr, d), p2(nullptr, d);
121 + p2 = std::move(p1);
122 +
123 + DDeleter dd;
124 +
125 + std::unique_ptr<int, DDeleter&> p1t(nullptr, dd);
126 + std::unique_ptr<int, Deleter&> p2t(nullptr, d);
127 + p2t = std::move(p1t);
128 +
129 + std::unique_ptr<int[], Deleter&> p1a(nullptr, d), p2a(nullptr, d);
130 + p2a = std::move(p1a);
131 +
132 + std::unique_ptr<int[], DDeleter&> p1at(nullptr, dd);
133 + std::unique_ptr<int[], Deleter&> p2at(nullptr, d);
134 + p2at = std::move(p1at);
135 +}
136 +
137 +int main()
138 +{
139 + test01();
140 + return 0;
141 +}
142 --
143 1.7.0.4
144