2 other tests needed to be adapted in 21_strings. Attached patch applied.

2019-05-17  François Dumont <fdum...@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.


On 5/16/19 11:05 AM, Jonathan Wakely wrote:
On 16/05/19 07:48 +0200, François Dumont wrote:
Hi

    Let's apply this resolution first before moving forward with the std::deque implementation.

    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.

I only run 23_containers tests with success so far, I'll complete the run before committing.

Nice, thanks for doing this.

Ok to commit ?

Yes, although I'd like one change ...

diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index d817ac4e838..a98869ed14f 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()))
+      { /*swap_base(a);*/ }

I don't think we should keep the /*swap_base(a);*/ comment. It just
confusing to have commented-out code that implements an old
behaviour.

OK for trunk with that /*...*/ comment removed.

Thanks again.




diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index c050d1bf023..358bbda3902 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -428,11 +428,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);
@@ -440,10 +436,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)
       {
@@ -555,29 +547,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 6ff64e67a7d..d021831caee 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 4edf9cad06d..66a5036c5b8 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 49d9c24ae9e..2eb66af9040 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 44592baf1a6..118ac235391 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 f0e9b55dc5f..e739fadacef 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 9d94009e44c..828e4dd7cc7 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 f2df25c7a45..a4cbe85158a 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 58d17e4b3bf..0ba27c95aac 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 a1e5ea59fe1..17b15611283 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 d377916a8da..577a2adb2de 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 34cdedc929c..e58199673d3 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 9abc5f5296a..92354241093 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 8f257871002..7243663ca51 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 5bca700f77d..2a2e3399425 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 903b1f9d6a2..b14ecb7d6e4 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 d817ac4e838..34dba16669f 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
       {

Reply via email to