]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
8fba412875dc170f530cc68dedab1c1a8fd1ca8a
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From 2ce87b6b9c9143a22381eec77bbf1fd7016e132d Mon Sep 17 00:00:00 2001
2 From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
3 Date: Sat, 16 Apr 2011 00:55:53 +0000
4 Subject: [PATCH 129/200] 2011-04-15 Daniel Krugler <daniel.kruegler@googlemail.com>
5 Paolo Carlini <paolo.carlini@oracle.com>
6
7 PR libstdc++/48635
8 * include/bits/unique_ptr.h (unique_ptr<>::operator=(unique_ptr&&),
9 unique_ptr<>::operator=(unique_ptr<>&&),
10 unique_ptr<_Tp[],>::operator=(unique_ptr&&),
11 unique_ptr<_Tp[],>::operator=(unique_ptr<>&&)): Forward the deleter
12 instead of moving it.
13 * testsuite/20_util/unique_ptr/assign/48635.cc: New.
14
15
16 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172533 138bc75d-0d04-0410-961f-82ee72b054a4
17
18 index 5df4325..1be2e7a 100644
19 --- a/libstdc++-v3/include/bits/unique_ptr.h
20 +++ b/libstdc++-v3/include/bits/unique_ptr.h
21 @@ -171,7 +171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
22 operator=(unique_ptr&& __u)
23 {
24 reset(__u.release());
25 - get_deleter() = std::move(__u.get_deleter());
26 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
27 return *this;
28 }
29
30 @@ -184,7 +184,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
31 operator=(unique_ptr<_Up, _Ep>&& __u)
32 {
33 reset(__u.release());
34 - get_deleter() = std::move(__u.get_deleter());
35 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
36 return *this;
37 }
38
39 @@ -315,7 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
40 operator=(unique_ptr&& __u)
41 {
42 reset(__u.release());
43 - get_deleter() = std::move(__u.get_deleter());
44 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
45 return *this;
46 }
47
48 @@ -324,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 operator=(unique_ptr<_Up, _Ep>&& __u)
50 {
51 reset(__u.release());
52 - get_deleter() = std::move(__u.get_deleter());
53 + get_deleter() = std::forward<deleter_type>(__u.get_deleter());
54 return *this;
55 }
56
57 diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
58 new file mode 100644
59 index 0000000..99b412b
60 --- /dev/null
61 +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc
62 @@ -0,0 +1,78 @@
63 +// { dg-options "-std=gnu++0x" }
64 +
65 +// Copyright (C) 2011 Free Software Foundation
66 +//
67 +// This file is part of the GNU ISO C++ Library. This library is free
68 +// software; you can redistribute it and/or modify it under the
69 +// terms of the GNU General Public License as published by the
70 +// Free Software Foundation; either version 3, or (at your option)
71 +// any later version.
72 +
73 +// This library is distributed in the hope that it will be useful,
74 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
75 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76 +// GNU General Public License for more details.
77 +
78 +// You should have received a copy of the GNU General Public License along
79 +// with this library; see the file COPYING3. If not see
80 +// <http://www.gnu.org/licenses/>.
81 +
82 +#include <memory>
83 +#include <testsuite_hooks.h>
84 +
85 +struct Deleter
86 +{
87 + Deleter() = default;
88 + Deleter(const Deleter&) = default;
89 + Deleter(Deleter&&) = default;
90 +
91 + Deleter&
92 + operator=(const Deleter&)
93 + {
94 + bool test __attribute__((unused)) = true;
95 + VERIFY( true );
96 + return *this;
97 + }
98 +
99 + Deleter&
100 + operator=(Deleter&&)
101 + {
102 + bool test __attribute__((unused)) = true;
103 + VERIFY( false );
104 + return *this;
105 + }
106 +
107 + template<class T>
108 + void
109 + operator()(T*) const { }
110 +};
111 +
112 +struct DDeleter : Deleter { };
113 +
114 +// libstdc++/48635
115 +void test01()
116 +{
117 + Deleter d;
118 +
119 + std::unique_ptr<int, Deleter&> p1(nullptr, d), p2(nullptr, d);
120 + p2 = std::move(p1);
121 +
122 + DDeleter dd;
123 +
124 + std::unique_ptr<int, DDeleter&> p1t(nullptr, dd);
125 + std::unique_ptr<int, Deleter&> p2t(nullptr, d);
126 + p2t = std::move(p1t);
127 +
128 + std::unique_ptr<int[], Deleter&> p1a(nullptr, d), p2a(nullptr, d);
129 + p2a = std::move(p1a);
130 +
131 + std::unique_ptr<int[], DDeleter&> p1at(nullptr, dd);
132 + std::unique_ptr<int[], Deleter&> p2at(nullptr, d);
133 + p2at = std::move(p1at);
134 +}
135 +
136 +int main()
137 +{
138 + test01();
139 + return 0;
140 +}
141 --
142 1.7.0.4
143