]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: _GLIBCXX_DEBUG Fix allocator-extended move constructor
authorFrançois Dumont <fdumont@gcc.gnu.org>
Fri, 26 Mar 2021 20:22:52 +0000 (21:22 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Sun, 28 Mar 2021 20:06:33 +0000 (22:06 +0200)
libstdc++-v3/ChangeLog:

* include/debug/forward_list
(forward_list(forward_list&&, const allocator_type&)): Add noexcept qualification.
* include/debug/list (list(list&&, const allocator_type&)): Likewise and add
call to safe container allocator aware move constructor.
* include/debug/vector (vector(vector&&, const allocator_type&)):
Fix noexcept qualification.
* testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc:
Add allocator-extended move constructor noexceot qualification check.
* testsuite/23_containers/list/cons/noexcept_move_construct.cc: Likewise.

libstdc++-v3/include/debug/forward_list
libstdc++-v3/include/debug/list
libstdc++-v3/include/debug/vector
libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc
libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc

index db46705cc71cff45dd259069f428122e51d8bff5..16f0531dce70a7b593a511616215e7bdecbf6e53 100644 (file)
@@ -239,8 +239,11 @@ namespace __debug
       { }
 
       forward_list(forward_list&& __list, const allocator_type& __al)
-       : _Safe(std::move(__list._M_safe()), __al),
-         _Base(std::move(__list._M_base()), __al)
+       noexcept(
+         std::is_nothrow_constructible<_Base,
+           _Base, const allocator_type&>::value )
+      : _Safe(std::move(__list._M_safe()), __al),
+       _Base(std::move(__list._M_base()), __al)
       { }
 
       explicit
index 06938899253891058bfc6d58ecfc8d72d7761343..01fe43fc7df960ce5a603fa53f1d98a9bd9496e9 100644 (file)
@@ -119,7 +119,11 @@ namespace __debug
       : _Base(__x, __a) { }
 
       list(list&& __x, const allocator_type& __a)
-      : _Base(std::move(__x), __a) { }
+       noexcept(
+         std::is_nothrow_constructible<_Base,
+           _Base, const allocator_type&>::value )
+      : _Safe(std::move(__x._M_safe()), __a),
+       _Base(std::move(__x._M_base()), __a) { }
 #endif
 
       explicit
index df179cbbfea5216f69a06cfee34d33ab12ad5cb2..987bba17c2b83027bbc486e9a02f82e523c657fa 100644 (file)
@@ -217,8 +217,9 @@ namespace __debug
       : _Base(__x, __a) { }
 
       vector(vector&& __x, const allocator_type& __a)
-      noexcept(noexcept(
-       _Base(std::declval<_Base&&>()), std::declval<const allocator_type&>()))
+      noexcept(
+       std::is_nothrow_constructible<_Base,
+         _Base, const allocator_type&>::value )
       : _Safe(std::move(__x._M_safe()), __a),
        _Base(std::move(__x._M_base()), __a),
        _Safe_vector(std::move(__x)) { }
index 96f3876e4f6ccebdd94dd773f5ed0e8bb09856d0..0eb5a5cdbba76462d2e2ef7418d2a1db3a77dbba 100644 (file)
@@ -23,4 +23,8 @@
 
 typedef std::forward_list<int> fltype;
 
-static_assert(std::is_nothrow_move_constructible<fltype>::value, "Error");
+static_assert( std::is_nothrow_move_constructible<fltype>::value,
+              "noexcept move constructor" );
+static_assert( std::is_nothrow_constructible<fltype,
+              fltype, const typename fltype::allocator_type&>::value,
+              "noexcept move constructor with allocator" );
index 5a2de10cf09b9daebae12958658fb01e160f1a10..858a0d763333fa5b99cb09e08d45fa327d99013e 100644 (file)
@@ -23,4 +23,8 @@
 
 typedef std::list<int> ltype;
 
-static_assert(std::is_nothrow_move_constructible<ltype>::value, "Error");
+static_assert( std::is_nothrow_move_constructible<ltype>::value,
+              "noexcept move constructor" );
+static_assert( std::is_nothrow_constructible<ltype,
+              ltype, const typename ltype::allocator_type&>::value,
+              "noexcept move constructor with allocator" );