From: François Dumont Date: Fri, 26 Mar 2021 20:22:52 +0000 (+0100) Subject: libstdc++: _GLIBCXX_DEBUG Fix allocator-extended move constructor X-Git-Tag: basepoints/gcc-12~375 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d04c246cae674da081e1c9d8ba631560fee2fa91;p=thirdparty%2Fgcc.git libstdc++: _GLIBCXX_DEBUG Fix allocator-extended move constructor 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. --- diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list index db46705cc71c..16f0531dce70 100644 --- a/libstdc++-v3/include/debug/forward_list +++ b/libstdc++-v3/include/debug/forward_list @@ -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 diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index 069388992538..01fe43fc7df9 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -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 diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index df179cbbfea5..987bba17c2b8 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -217,8 +217,9 @@ namespace __debug : _Base(__x, __a) { } vector(vector&& __x, const allocator_type& __a) - noexcept(noexcept( - _Base(std::declval<_Base&&>()), std::declval())) + 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)) { } diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc index 96f3876e4f6c..0eb5a5cdbba7 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc @@ -23,4 +23,8 @@ typedef std::forward_list fltype; -static_assert(std::is_nothrow_move_constructible::value, "Error"); +static_assert( std::is_nothrow_move_constructible::value, + "noexcept move constructor" ); +static_assert( std::is_nothrow_constructible::value, + "noexcept move constructor with allocator" ); diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc b/libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc index 5a2de10cf09b..858a0d763333 100644 --- a/libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc +++ b/libstdc++-v3/testsuite/23_containers/list/cons/noexcept_move_construct.cc @@ -23,4 +23,8 @@ typedef std::list ltype; -static_assert(std::is_nothrow_move_constructible::value, "Error"); +static_assert( std::is_nothrow_move_constructible::value, + "noexcept move constructor" ); +static_assert( std::is_nothrow_constructible::value, + "noexcept move constructor with allocator" );