From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2100) id CA191386F02A; Tue, 18 Aug 2020 00:33:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA191386F02A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597710832; bh=o/efBtTp9v+vdDFv9p2A2gPxQKOVXhGZ/a9VE7QHnAg=; h=From:To:Subject:Date:From; b=Jgexx24FVEVtONc5PweLn7TQ/xY8VsAeF+eG+XKL0CJdGa5r3va/VNrARESNpYb/O DrVcN/JM6nodau9BAg+4xcGh3IdtFyinVQ77qxycRY2IOuPJ+Pz4lCJJ/2z38EVoGq kXPdKo3BhwqZk/cNUawe2rHV3h/36mol8mZyEVNQ= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Giuliano Belinassi To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/giulianob/heads/autopar_rebase2)] libstdc++: Fix [multi]map/[multi]set move constructors noexcept qualification X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Git-Refname: refs/users/giulianob/heads/autopar_rebase2 X-Git-Oldrev: d1b5f7d98f1be9b57ce0f75d97ea6caa0c95aab1 X-Git-Newrev: e395c4ad40bfb9713ae1b052ffcfbebd90b632c1 Message-Id: <20200818003352.CA191386F02A@sourceware.org> Date: Tue, 18 Aug 2020 00:33:52 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Aug 2020 00:33:52 -0000 https://gcc.gnu.org/g:e395c4ad40bfb9713ae1b052ffcfbebd90b632c1 commit e395c4ad40bfb9713ae1b052ffcfbebd90b632c1 Author: François Dumont Date: Fri Jul 3 08:13:19 2020 +0200 libstdc++: Fix [multi]map/[multi]set move constructors noexcept qualification Container move constructors shall not consider their allocator move constructor qualification. libstdc++-v3/ChangeLog: * include/bits/stl_tree.h (_Rb_tree_impl(_Rb_tree_impl&&)): Add noexcept qualification based only on _Compare one. * testsuite/23_containers/map/cons/noexcept_move_construct.cc: Add static asserts. * testsuite/23_containers/multimap/cons/noexcept_move_construct.cc: Likewise. * testsuite/23_containers/multiset/cons/noexcept_move_construct.cc: Likewise. * testsuite/23_containers/set/cons/noexcept_move_construct.cc: Likewise. Diff: --- libstdc++-v3/include/bits/stl_tree.h | 4 ++- .../map/cons/noexcept_move_construct.cc | 32 +++++++++++++++++++++- .../multimap/cons/noexcept_move_construct.cc | 32 +++++++++++++++++++++- .../multiset/cons/noexcept_move_construct.cc | 32 +++++++++++++++++++++- .../set/cons/noexcept_move_construct.cc | 32 +++++++++++++++++++++- 5 files changed, 127 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 5be15afa257..21b72cebf2e 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -698,7 +698,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Node_allocator(__a), _Base_key_compare(__comp) { } #else - _Rb_tree_impl(_Rb_tree_impl&&) = default; + _Rb_tree_impl(_Rb_tree_impl&&) + noexcept( is_nothrow_move_constructible<_Base_key_compare>::value ) + = default; explicit _Rb_tree_impl(_Node_allocator&& __a) diff --git a/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_move_construct.cc b/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_move_construct.cc index 119b199ddff..25d1c9b5aca 100644 --- a/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_move_construct.cc +++ b/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_move_construct.cc @@ -29,6 +29,33 @@ static_assert( std::is_nothrow_constructible::value, "noexcept move constructor with allocator" ); +template + class not_noexcept_move_constructor_alloc : public std::allocator + { + public: + not_noexcept_move_constructor_alloc() noexcept { } + + not_noexcept_move_constructor_alloc( + const not_noexcept_move_constructor_alloc& x) noexcept + : std::allocator(x) + { } + + not_noexcept_move_constructor_alloc( + not_noexcept_move_constructor_alloc&& x) noexcept(false) + : std::allocator(std::move(x)) + { } + + template + struct rebind + { typedef not_noexcept_move_constructor_alloc<_Tp1> other; }; + }; + +typedef std::map, + not_noexcept_move_constructor_alloc>> amtype; + +static_assert( std::is_nothrow_move_constructible::value, + "noexcept move constructor with not noexcept alloc" ); + struct not_noexcept_less { not_noexcept_less() = default; @@ -42,6 +69,9 @@ struct not_noexcept_less typedef std::map emtype; +static_assert( !std::is_nothrow_move_constructible::value, + "not noexcept move constructor with not noexcept less" ); + static_assert( !std::is_nothrow_constructible::value, - "except move constructor with allocator" ); + "not noexcept move constructor with allocator" ); diff --git a/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_move_construct.cc b/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_move_construct.cc index 44c3015a282..af545ae297c 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_move_construct.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_move_construct.cc @@ -29,6 +29,33 @@ static_assert( std::is_nothrow_constructible::value, "noexcept move constructor with allocator" ); +template + class not_noexcept_move_constructor_alloc : public std::allocator + { + public: + not_noexcept_move_constructor_alloc() noexcept { } + + not_noexcept_move_constructor_alloc( + const not_noexcept_move_constructor_alloc& x) noexcept + : std::allocator(x) + { } + + not_noexcept_move_constructor_alloc( + not_noexcept_move_constructor_alloc&& x) noexcept(false) + : std::allocator(std::move(x)) + { } + + template + struct rebind + { typedef not_noexcept_move_constructor_alloc<_Tp1> other; }; + }; + +typedef std::multimap, + not_noexcept_move_constructor_alloc>> ammtype; + +static_assert( std::is_nothrow_move_constructible::value, + "noexcept move constructor with not noexcept alloc" ); + struct not_noexcept_less { not_noexcept_less() = default; @@ -42,6 +69,9 @@ struct not_noexcept_less typedef std::multimap emmtype; +static_assert( !std::is_nothrow_move_constructible::value, + "not noexcept move constructor with not noexcept less" ); + static_assert( !std::is_nothrow_constructible::value, - "except move constructor with allocator" ); + "not noexcept move constructor with allocator" ); diff --git a/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_move_construct.cc b/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_move_construct.cc index 225b2206ad4..ed4d9128606 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_move_construct.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_move_construct.cc @@ -29,6 +29,33 @@ static_assert( std::is_nothrow_constructible::value, "noexcept move constructor with allocator" ); +template + class not_noexcept_move_constructor_alloc : public std::allocator + { + public: + not_noexcept_move_constructor_alloc() noexcept { } + + not_noexcept_move_constructor_alloc( + const not_noexcept_move_constructor_alloc& x) noexcept + : std::allocator(x) + { } + + not_noexcept_move_constructor_alloc( + not_noexcept_move_constructor_alloc&& x) noexcept(false) + : std::allocator(std::move(x)) + { } + + template + struct rebind + { typedef not_noexcept_move_constructor_alloc<_Tp1> other; }; + }; + +typedef std::multiset, + not_noexcept_move_constructor_alloc> amstype; + +static_assert( std::is_nothrow_move_constructible::value, + "noexcept move constructor with not noexcept alloc" ); + struct not_noexcept_less { not_noexcept_less() = default; @@ -42,6 +69,9 @@ struct not_noexcept_less typedef std::multiset emstype; +static_assert( !std::is_nothrow_move_constructible::value, + "not noexcept move constructor with not noexcept less" ); + static_assert( !std::is_nothrow_constructible::value, - "except move constructor with allocator" ); + "not noexcept move constructor with allocator" ); diff --git a/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_move_construct.cc b/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_move_construct.cc index acd84a8fcd0..dc96236a668 100644 --- a/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_move_construct.cc +++ b/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_move_construct.cc @@ -29,6 +29,33 @@ static_assert( std::is_nothrow_constructible::value, "noexcept move constructor with allocator" ); +template + class not_noexcept_move_constructor_alloc : public std::allocator + { + public: + not_noexcept_move_constructor_alloc() noexcept { } + + not_noexcept_move_constructor_alloc( + const not_noexcept_move_constructor_alloc& x) noexcept + : std::allocator(x) + { } + + not_noexcept_move_constructor_alloc( + not_noexcept_move_constructor_alloc&& x) noexcept(false) + : std::allocator(std::move(x)) + { } + + template + struct rebind + { typedef not_noexcept_move_constructor_alloc<_Tp1> other; }; + }; + +typedef std::set, + not_noexcept_move_constructor_alloc> astype; + +static_assert( std::is_nothrow_move_constructible::value, + "noexcept move constructor with not noexcept alloc" ); + struct not_noexcept_less { not_noexcept_less() = default; @@ -42,6 +69,9 @@ struct not_noexcept_less typedef std::set estype; +static_assert( !std::is_nothrow_move_constructible::value, + "not noexcept move constructor with not noexcept less" ); + static_assert( !std::is_nothrow_constructible::value, - "except move constructor with allocator" ); + "not noexcept move constructor with allocator" );