aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Dumont <fdumont@gcc.gnu.org>2019-05-17 04:55:37 +0000
committerFrançois Dumont <fdumont@gcc.gnu.org>2019-05-17 04:55:37 +0000
commit935469daaa5c02ac5104c0d5c04a1f12e23529b1 (patch)
tree37f387121dc323ef876f4df0a95dcd0abae8623b
parent395389bf9492a69db79747943d32abd0b7ac36c3 (diff)
downloadgcc-935469daaa5c02ac5104c0d5c04a1f12e23529b1.zip
gcc-935469daaa5c02ac5104c0d5c04a1f12e23529b1.tar.gz
gcc-935469daaa5c02ac5104c0d5c04a1f12e23529b1.tar.bz2
Move from state of allocators (LWG2593)
2019-05-17 François Dumont <fdumont@gcc.gnu.org> Move from state of allocators (LWG2593) * include/bits/stl_deque.h (_Deque_base(_Deque_base&&, false_type)): Remove. (_Deque_base(_Deque_base&&, true_type)): Remove. (_Deque_base(_Deque_base&&)): Adapt. (_Deque_base::_M_move_impl()): Remove. * testsuite/util/testsuite_allocator.h (propagating_allocator(propagating_allocator&&)): Preserve move from state. * testsuite/23_containers/deque/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/forward_list/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/list/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/map/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/multimap/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/multiset/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/set/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/unordered_map/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/unordered_multimap/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/unordered_multiset/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/unordered_set/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/vector/allocator/move_assign.cc (test02): Adapt. * testsuite/23_containers/vector/bool/allocator/move_assign.cc (test02): Adapt. * testsuite/21_strings/basic_string/allocator/char/move_assign.cc (test02): Adapt. * testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc (test02): Adapt. From-SVN: r271309
-rw-r--r--libstdc++-v3/ChangeLog39
-rw-r--r--libstdc++-v3/include/bits/stl_deque.h33
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc8
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc8
-rw-r--r--libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/bool/allocator/move_assign.cc2
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_allocator.h8
18 files changed, 65 insertions, 57 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 934d513..5ba8c22 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,42 @@
+2019-05-17 François Dumont <fdumont@gcc.gnu.org>
+
+ Move from state of allocators (LWG2593)
+ * include/bits/stl_deque.h
+ (_Deque_base(_Deque_base&&, false_type)): Remove.
+ (_Deque_base(_Deque_base&&, true_type)): Remove.
+ (_Deque_base(_Deque_base&&)): Adapt.
+ (_Deque_base::_M_move_impl()): Remove.
+ * testsuite/util/testsuite_allocator.h
+ (propagating_allocator(propagating_allocator&&)): Preserve move from
+ state.
+ * testsuite/23_containers/deque/allocator/move_assign.cc (test02):
+ Adapt.
+ * testsuite/23_containers/forward_list/allocator/move_assign.cc (test02):
+ Adapt.
+ * testsuite/23_containers/list/allocator/move_assign.cc (test02): Adapt.
+ * testsuite/23_containers/map/allocator/move_assign.cc (test02): Adapt.
+ * testsuite/23_containers/multimap/allocator/move_assign.cc (test02):
+ Adapt.
+ * testsuite/23_containers/multiset/allocator/move_assign.cc (test02):
+ Adapt.
+ * testsuite/23_containers/set/allocator/move_assign.cc (test02): Adapt.
+ * testsuite/23_containers/unordered_map/allocator/move_assign.cc
+ (test02): Adapt.
+ * testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
+ (test02): Adapt.
+ * testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
+ (test02): Adapt.
+ * testsuite/23_containers/unordered_set/allocator/move_assign.cc
+ (test02): Adapt.
+ * testsuite/23_containers/vector/allocator/move_assign.cc (test02):
+ Adapt.
+ * testsuite/23_containers/vector/bool/allocator/move_assign.cc (test02):
+ Adapt.
+ * testsuite/21_strings/basic_string/allocator/char/move_assign.cc
+ (test02): Adapt.
+ * testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
+ (test02): Adapt.
+
2019-05-16 Jonathan Wakely <jwakely@redhat.com>
* src/c++17/fs_ops.cc (absolute(const path&, error_code&))
diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index 6e0f6dc..d0b46c6 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -500,11 +500,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ /* Caller must initialize map. */ }
#if __cplusplus >= 201103L
- _Deque_base(_Deque_base&& __x, false_type)
- : _M_impl(__x._M_move_impl())
- { }
-
- _Deque_base(_Deque_base&& __x, true_type)
+ _Deque_base(_Deque_base&& __x)
: _M_impl(std::move(__x._M_get_Tp_allocator()))
{
_M_initialize_map(0);
@@ -512,10 +508,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
this->_M_impl._M_swap_data(__x._M_impl);
}
- _Deque_base(_Deque_base&& __x)
- : _Deque_base(std::move(__x), typename _Alloc_traits::is_always_equal{})
- { }
-
_Deque_base(_Deque_base&& __x, const allocator_type& __a, size_t __n)
: _M_impl(__a)
{
@@ -627,29 +619,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
enum { _S_initial_map_size = 8 };
_Deque_impl _M_impl;
-
-#if __cplusplus >= 201103L
- private:
- _Deque_impl
- _M_move_impl()
- {
- if (!_M_impl._M_map)
- return std::move(_M_impl);
-
- // Create a copy of the current allocator.
- _Tp_alloc_type __alloc{_M_get_Tp_allocator()};
- // Put that copy in a moved-from state.
- _Tp_alloc_type __sink __attribute((__unused__)) {std::move(__alloc)};
- // Create an empty map that allocates using the moved-from allocator.
- _Deque_base __empty{__alloc};
- __empty._M_initialize_map(0);
- // Now safe to modify current allocator and perform non-throwing swaps.
- _Deque_impl __ret{std::move(_M_get_Tp_allocator())};
- _M_impl._M_swap_data(__ret);
- _M_impl._M_swap_data(__empty._M_impl);
- return __ret;
- }
-#endif
};
template<typename _Tp, typename _Alloc>
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
index 6ff64e6..d021831 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
@@ -80,7 +80,7 @@ void test02()
test_type v2(alloc_type(2));
v2.assign(1, c);
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
test_type v3(alloc_type(3));
@@ -88,7 +88,7 @@ void test02()
test_type v4(alloc_type(4));
v4.assign(100, c);
v4 = std::move(v3);
- VERIFY(0 == v3.get_allocator().get_personality());
+ VERIFY(3 == v3.get_allocator().get_personality());
VERIFY(3 == v4.get_allocator().get_personality());
test_type v5(alloc_type(5));
@@ -96,7 +96,7 @@ void test02()
test_type v6(alloc_type(6));
v6.assign(1, c);
v6 = std::move(v5);
- VERIFY(0 == v5.get_allocator().get_personality());
+ VERIFY(5 == v5.get_allocator().get_personality());
VERIFY(5 == v6.get_allocator().get_personality());
test_type v7(alloc_type(7));
@@ -104,7 +104,7 @@ void test02()
test_type v8(alloc_type(8));
v8.assign(100, c);
v8 = std::move(v7);
- VERIFY(0 == v7.get_allocator().get_personality());
+ VERIFY(7 == v7.get_allocator().get_personality());
VERIFY(7 == v8.get_allocator().get_personality());
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
index 4edf9ca..66a5036 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
@@ -80,7 +80,7 @@ void test02()
test_type v2(alloc_type(2));
v2.assign(1, c);
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
test_type v3(alloc_type(3));
@@ -88,7 +88,7 @@ void test02()
test_type v4(alloc_type(4));
v4.assign(100, c);
v4 = std::move(v3);
- VERIFY(0 == v3.get_allocator().get_personality());
+ VERIFY(3 == v3.get_allocator().get_personality());
VERIFY(3 == v4.get_allocator().get_personality());
test_type v5(alloc_type(5));
@@ -96,7 +96,7 @@ void test02()
test_type v6(alloc_type(6));
v6.assign(1, c);
v6 = std::move(v5);
- VERIFY(0 == v5.get_allocator().get_personality());
+ VERIFY(5 == v5.get_allocator().get_personality());
VERIFY(5 == v6.get_allocator().get_personality());
test_type v7(alloc_type(7));
@@ -104,7 +104,7 @@ void test02()
test_type v8(alloc_type(8));
v8.assign(100, c);
v8 = std::move(v7);
- VERIFY(0 == v7.get_allocator().get_personality());
+ VERIFY(7 == v7.get_allocator().get_personality());
VERIFY(7 == v8.get_allocator().get_personality());
}
diff --git a/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign.cc
index 49d9c24..2eb66af 100644
--- a/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign.cc
@@ -45,7 +45,7 @@ void test02()
test_type v2(1, alloc_type(2));
v2 = std::move(v1);
VERIFY( it == v2.begin() );
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc
index 44592ba..118ac23 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc
@@ -48,7 +48,7 @@ void test02()
test_type v2(alloc_type(2));
v2.push_front(T());
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
diff --git a/libstdc++-v3/testsuite/23_containers/list/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/list/allocator/move_assign.cc
index f0e9b55..e739fada 100644
--- a/libstdc++-v3/testsuite/23_containers/list/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/allocator/move_assign.cc
@@ -48,7 +48,7 @@ void test02()
test_type v2(alloc_type(2));
v2.push_front(T());
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
diff --git a/libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc
index 9d94009..828e4dd 100644
--- a/libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc
@@ -58,7 +58,7 @@ void test02()
v2 = { test_type::value_type{} };
v2 = std::move(v1);
- VERIFY( 0 == v1.get_allocator().get_personality() );
+ VERIFY( 1 == v1.get_allocator().get_personality() );
VERIFY( 1 == v2.get_allocator().get_personality() );
VERIFY( it == v2.begin() );
}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc
index f2df25c..a4cbe85 100644
--- a/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc
@@ -54,7 +54,7 @@ void test02()
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc
index 58d17e4..0ba27c9 100644
--- a/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc
@@ -52,7 +52,7 @@ void test02()
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
diff --git a/libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc
index a1e5ea5..17b1561 100644
--- a/libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc
@@ -55,7 +55,7 @@ void test02()
test_type v2(alloc_type(2));
v2 = { test_type::value_type{} };
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( it == v2.begin() );
}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc
index d377916..577a2ad 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc
@@ -76,7 +76,7 @@ void test02()
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( counter_type::move_assign_count == 0 );
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
index 34cdedc..e581996 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
@@ -76,7 +76,7 @@ void test02()
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( counter_type::move_assign_count == 0 );
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
index 9abc5f5..9235424 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
@@ -70,7 +70,7 @@ void test02()
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( counter_type::move_count == 0 );
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc
index 8f25787..7243663 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc
@@ -86,7 +86,7 @@ void test02()
v2 = std::move(v1);
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
VERIFY( counter_type::move_count == 0 );
diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc
index 5bca700..2a2e339 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc
@@ -49,7 +49,7 @@ void test02()
v2.push_back(T());
v2 = std::move(v1);
VERIFY( it == v2.begin() );
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/move_assign.cc
index 903b1f9..b14ecb7 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/move_assign.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/move_assign.cc
@@ -49,7 +49,7 @@ void test02()
v2.push_back(T());
v2 = std::move(v1);
VERIFY( it == v2.begin() );
- VERIFY(0 == v1.get_allocator().get_personality());
+ VERIFY(1 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality());
}
diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index d817ac4..34dba16 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -465,12 +465,12 @@ namespace __gnu_test
return *this;
}
- // postcondition: a.get_personality() == 0
+ // postcondition: LWG2593 a.get_personality() un-changed.
propagating_allocator(propagating_allocator&& a) noexcept
- : base_alloc()
- { swap_base(a); }
+ : base_alloc(std::move(a.base()))
+ { }
- // postcondition: a.get_personality() == 0
+ // postcondition: LWG2593 a.get_personality() un-changed
propagating_allocator&
operator=(propagating_allocator&& a) noexcept
{