]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
77864 Fix noexcept conditions for map/set default constructors
authorJonathan Wakely <jwakely@redhat.com>
Wed, 5 Oct 2016 13:43:58 +0000 (14:43 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 5 Oct 2016 13:43:58 +0000 (14:43 +0100)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_map.h
libstdc++-v3/include/bits/stl_multimap.h
libstdc++-v3/include/bits/stl_multiset.h
libstdc++-v3/include/bits/stl_set.h
libstdc++-v3/testsuite/23_containers/map/cons/noexcept_default_construct.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multimap/cons/noexcept_default_construct.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multiset/cons/noexcept_default_construct.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/set/cons/noexcept_default_construct.cc [new file with mode: 0644]

index 4c61b56ec67abc2d2e83fc0f604a0ae371220ce9..4e54c0ca8dfd9d94234ebf376df6f8030c5d3f0d 100644 (file)
@@ -1,3 +1,20 @@
+2016-10-05  Jonathan Wakely  <jwakely@redhat.com>
+
+       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  <jwakely@redhat.com>
 
        PR libstdc++/68323
index 179e3f2a0bdeb71edbb1bd0dcdd3b5f3367c291b..04345c58101b33a0a184782bd6f0263a09a114d2 100644 (file)
@@ -161,7 +161,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        */
       map()
 #if __cplusplus >= 201103L
-      noexcept(is_nothrow_default_constructible<allocator_type>::value)
+      noexcept(is_nothrow_default_constructible<allocator_type>::value
+               && is_nothrow_default_constructible<key_compare>::value)
 #endif
       : _M_t() { }
 
index 10ac0fadea8855664673534d4debf678877509ff..20076a1fd0439b349374c3c3c6c275462df36e3a 100644 (file)
@@ -159,7 +159,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        */
       multimap()
 #if __cplusplus >= 201103L
-      noexcept(is_nothrow_default_constructible<allocator_type>::value)
+      noexcept(is_nothrow_default_constructible<allocator_type>::value
+               && is_nothrow_default_constructible<key_compare>::value)
 #endif
       : _M_t() { }
 
index ffe15ae31647fb0c1b8c2e2be62034f462602d58..3a947d53fba49d7f2301027653a39d9bb25ca4fb 100644 (file)
@@ -139,7 +139,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        */
       multiset()
 #if __cplusplus >= 201103L
-      noexcept(is_nothrow_default_constructible<allocator_type>::value)
+      noexcept(is_nothrow_default_constructible<allocator_type>::value
+               && is_nothrow_default_constructible<key_compare>::value)
 #endif
       : _M_t() { }
 
index 35cdf71701c501e0da7220f96a85fd9ad36aec9f..805fd0788f7ae6bcceccc425f0a2ac069eccc19c 100644 (file)
@@ -141,7 +141,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        */
       set()
 #if __cplusplus >= 201103L
-      noexcept(is_nothrow_default_constructible<allocator_type>::value)
+      noexcept(is_nothrow_default_constructible<allocator_type>::value
+               && is_nothrow_default_constructible<key_compare>::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 (file)
index 0000000..1cb33c1
--- /dev/null
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <map>
+
+using mtype1 = std::map<int, int>;
+static_assert(std::is_nothrow_default_constructible<mtype1>::value, "Error");
+
+struct cmp
+{
+  cmp() { }
+  bool operator()(int, int) const;
+};
+
+using mtype2 = std::map<int, int, cmp>;
+static_assert( !std::is_nothrow_default_constructible<mtype2>::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 (file)
index 0000000..69239dc
--- /dev/null
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <map>
+
+using mtype1 = std::multimap<int, int>;
+static_assert(std::is_nothrow_default_constructible<mtype1>::value, "Error");
+
+struct cmp
+{
+  cmp() { }
+  bool operator()(int, int) const;
+};
+
+using mtype2 = std::multimap<int, int, cmp>;
+static_assert( !std::is_nothrow_default_constructible<mtype2>::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 (file)
index 0000000..6b003f0
--- /dev/null
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <set>
+
+using stype1 = std::multiset<int>;
+static_assert(std::is_nothrow_default_constructible<stype1>::value, "Error");
+
+struct cmp
+{
+  cmp() { }
+  bool operator()(int, int) const;
+};
+
+using stype2 = std::multiset<int, cmp>;
+static_assert( !std::is_nothrow_default_constructible<stype2>::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 (file)
index 0000000..5ba42b8
--- /dev/null
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <set>
+
+using stype1 = std::set<int>;
+static_assert(std::is_nothrow_default_constructible<stype1>::value, "Error");
+
+struct cmp
+{
+  cmp() { }
+  bool operator()(int, int) const;
+};
+
+using stype2 = std::set<int, cmp>;
+static_assert( !std::is_nothrow_default_constructible<stype2>::value, "Error");