From: Jonathan Wakely Date: Wed, 5 Oct 2016 13:43:58 +0000 (+0100) Subject: 77864 Fix noexcept conditions for map/set default constructors X-Git-Tag: releases/gcc-5.5.0~790 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09b5f8a00e96feb00994492f4a4417c9fb9b7370;p=thirdparty%2Fgcc.git 77864 Fix noexcept conditions for map/set default constructors PR libstdc++/77864 * include/bits/stl_map.h (map::map()): Use nothrow constructibility of comparison function in conditional noexcept. * include/bits/stl_multimap.h (multimap::multimap()): Likewise. * include/bits/stl_multiset.h (multiset::multiset()): Likewise. * include/bits/stl_set.h (set::set()): Likewise. * testsuite/23_containers/map/cons/noexcept_default_construct.cc: New test. * testsuite/23_containers/multimap/cons/noexcept_default_construct.cc: Likewise. * testsuite/23_containers/multiset/cons/noexcept_default_construct.cc: Likewise. * testsuite/23_containers/set/cons/noexcept_default_construct.cc: Likewise. From-SVN: r240789 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4c61b56ec67a..4e54c0ca8dfd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2016-10-05 Jonathan Wakely + + PR libstdc++/77864 + * include/bits/stl_map.h (map::map()): Use nothrow constructibility + of comparison function in conditional noexcept. + * include/bits/stl_multimap.h (multimap::multimap()): Likewise. + * include/bits/stl_multiset.h (multiset::multiset()): Likewise. + * include/bits/stl_set.h (set::set()): Likewise. + * testsuite/23_containers/map/cons/noexcept_default_construct.cc: + New test. + * testsuite/23_containers/multimap/cons/noexcept_default_construct.cc: + Likewise. + * testsuite/23_containers/multiset/cons/noexcept_default_construct.cc: + Likewise. + * testsuite/23_containers/set/cons/noexcept_default_construct.cc: + Likewise. + 2016-10-03 Jonathan Wakely PR libstdc++/68323 diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 179e3f2a0bde..04345c58101b 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -161,7 +161,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ map() #if __cplusplus >= 201103L - noexcept(is_nothrow_default_constructible::value) + noexcept(is_nothrow_default_constructible::value + && is_nothrow_default_constructible::value) #endif : _M_t() { } diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 10ac0fadea88..20076a1fd043 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -159,7 +159,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ multimap() #if __cplusplus >= 201103L - noexcept(is_nothrow_default_constructible::value) + noexcept(is_nothrow_default_constructible::value + && is_nothrow_default_constructible::value) #endif : _M_t() { } diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index ffe15ae31647..3a947d53fba4 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -139,7 +139,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ multiset() #if __cplusplus >= 201103L - noexcept(is_nothrow_default_constructible::value) + noexcept(is_nothrow_default_constructible::value + && is_nothrow_default_constructible::value) #endif : _M_t() { } diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 35cdf71701c5..805fd0788f7a 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -141,7 +141,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ set() #if __cplusplus >= 201103L - noexcept(is_nothrow_default_constructible::value) + noexcept(is_nothrow_default_constructible::value + && is_nothrow_default_constructible::value) #endif : _M_t() { } diff --git a/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_default_construct.cc b/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_default_construct.cc new file mode 100644 index 000000000000..1cb33c1449dd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/cons/noexcept_default_construct.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using mtype1 = std::map; +static_assert(std::is_nothrow_default_constructible::value, "Error"); + +struct cmp +{ + cmp() { } + bool operator()(int, int) const; +}; + +using mtype2 = std::map; +static_assert( !std::is_nothrow_default_constructible::value, "Error"); diff --git a/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_default_construct.cc b/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_default_construct.cc new file mode 100644 index 000000000000..69239dcd569b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_default_construct.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using mtype1 = std::multimap; +static_assert(std::is_nothrow_default_constructible::value, "Error"); + +struct cmp +{ + cmp() { } + bool operator()(int, int) const; +}; + +using mtype2 = std::multimap; +static_assert( !std::is_nothrow_default_constructible::value, "Error"); diff --git a/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_default_construct.cc b/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_default_construct.cc new file mode 100644 index 000000000000..6b003f0fa6d6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_default_construct.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using stype1 = std::multiset; +static_assert(std::is_nothrow_default_constructible::value, "Error"); + +struct cmp +{ + cmp() { } + bool operator()(int, int) const; +}; + +using stype2 = std::multiset; +static_assert( !std::is_nothrow_default_constructible::value, "Error"); diff --git a/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_default_construct.cc b/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_default_construct.cc new file mode 100644 index 000000000000..5ba42b8c8053 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/cons/noexcept_default_construct.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include + +using stype1 = std::set; +static_assert(std::is_nothrow_default_constructible::value, "Error"); + +struct cmp +{ + cmp() { } + bool operator()(int, int) const; +}; + +using stype2 = std::set; +static_assert( !std::is_nothrow_default_constructible::value, "Error");