]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add _GLIBCXX_DEBUG checks on unordered container local_iterator
authorFrançois Dumont <frs.dumont@gmail.com>
Tue, 8 Apr 2025 17:35:28 +0000 (19:35 +0200)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Fri, 18 Apr 2025 19:26:46 +0000 (21:26 +0200)
Complete tests on  _GLIBCXX_DEBUG checks in include/debug/safe_local_iterator.h.

Fix several tests not testing the container corresponding to their location in the
testsuite directory.

libstdc++-v3/ChangeLog:

* testsuite/util/debug/unordered_checks.h (fill_container): New helper method.
(use_erased_local_iterator, invalid_local_iterator_pre_increment)
(invalid_local_iterator_post_increment, invalid_local_iterator_compare)
(invalid_local_iterator_range): Use latter.
(fill_and_get_local_iterator): New, use fill_container.
(use_invalid_local_iterator): Use latter.
(invalid_local_iterator_arrow_operator): New test function.
(invalid_local_iterator_copy_instantiation): New test function.
(invalid_local_iterator_move_instantiation): New test function.
(invalid_local_iterator_copy_assignment): New test function.
(invalid_local_iterator_move_assignment): New test function.
(invalid_local_iterator_const_conversion): New test function.
* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_arrow_operator_neg.cc:
New test case.
* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_const_conversion_neg.cc:
New test case.
* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_construction_neg.cc:
New test case.
* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_construction_neg.cc:
New test case.
* testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc: Test unordered_map.
* testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc: Test unordered_multimap.
* testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc: Likewise.
* testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc: Likewise.
* testsuite/23_containers/unordered_multimap/debug/cend_neg.cc: Likewise.
* testsuite/23_containers/unordered_multimap/debug/end1_neg.cc: Likewise.
* testsuite/23_containers/unordered_multimap/debug/end2_neg.cc: Likewise.
* testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_arrow_operator_neg.cc:
New test case.
* testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_const_conversion_neg.cc:
New test case.
* testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_construction_neg.cc:
New test case.
* testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_construction_neg.cc:
New test case.
* testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc:
Test unordered_multimap.
* testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_arrow_operator_neg.cc:
New test case.
* testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_const_conversion_neg.cc:
New test case.
* testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_construction_neg.cc:
New test case.
* testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_construction_neg.cc:
New test case.
* testsuite/23_containers/unordered_set/debug/invalid_local_iterator_arrow_operator_neg.cc:
New test case.
* testsuite/23_containers/unordered_set/debug/invalid_local_iterator_const_conversion_neg.cc:
New test case.
* testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_construction_neg.cc:
New test case.
* testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_assignment_neg.cc:
New test case.
* testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_construction_neg.cc:
New test case.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
33 files changed:
libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_arrow_operator_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_const_conversion_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_arrow_operator_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_const_conversion_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc
libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_arrow_operator_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_const_conversion_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_arrow_operator_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_const_conversion_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_assignment_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_construction_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/util/debug/unordered_checks.h

diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_arrow_operator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_arrow_operator_neg.cc
new file mode 100644 (file)
index 0000000..09870a7
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_arrow_operator
+    <std::unordered_map<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_const_conversion_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_const_conversion_neg.cc
new file mode 100644 (file)
index 0000000..7bfe3a8
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_const_conversion
+    <std::unordered_map<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_assignment_neg.cc
new file mode 100644 (file)
index 0000000..d3b671b
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_assignment
+    <std::unordered_map<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_construction_neg.cc
new file mode 100644 (file)
index 0000000..d609671
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_construction
+    <std::unordered_map<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_assignment_neg.cc
new file mode 100644 (file)
index 0000000..8d2ed6b
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_assignment
+    <std::unordered_map<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_construction_neg.cc
new file mode 100644 (file)
index 0000000..dd9b7dc
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_construction
+    <std::unordered_map<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 7fbc453f0452cc940db788bc863e9df9ee207c21..25967980dc9de07c2b95d7dfc159000baff4873b 100644 (file)
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_multimap<int, int> um;
+  std::unordered_map<int, int> um;
   um.max_load_factor(-1.0f);
 }
 
index ff787cf6f4a93973df0e8f28dcefe7f2bc845e19..b2d67fbaa0028caaf0b75e5a04b37778f0abd53c 100644 (file)
@@ -22,8 +22,8 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
-  const std::unordered_map<int, int>& cum = um;
+  std::unordered_multimap<int, int> um;
+  const std::unordered_multimap<int, int>& cum = um;
   cum.begin(um.bucket_count());
 }
 
index b5ddb18af8f0e3d2ca2165e1cf366260a17cbaf7..4d5cb846a64ca8610e7d2f43e78190269a968b95 100644 (file)
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.bucket_size(um.bucket_count());
 }
 
index 5ba1da56aa549bd31ac5631d11eb8a1ca8d2ed8b..654d4091fb36052dad54a0584cf2040b925e85cf 100644 (file)
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.cbegin(um.bucket_count());
 }
 
index 031be37e0e7b532b77c00e65948eeb376a7365c9..f7149d40f51eaa0e41f89c075d02b98e572f327b 100644 (file)
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.cend(um.bucket_count());
 }
 
index d412fcf9e4e7b876e789ae2eb5003670a66a25dc..fd0f981b4e458f17dfa7f04bc04c722fad86920e 100644 (file)
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.end(um.bucket_count());
 }
 
index 0115351df9447297c87cbb9a532f947cc2125a26..0c3f86c43596a3e77c4eae49aca01bddf73efb9f 100644 (file)
@@ -22,8 +22,8 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
-  const std::unordered_map<int, int>& cum = um;
+  std::unordered_multimap<int, int> um;
+  const std::unordered_multimap<int, int>& cum = um;
   cum.end(um.bucket_count());
 }
 
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_arrow_operator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_arrow_operator_neg.cc
new file mode 100644 (file)
index 0000000..8b23020
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_arrow_operator
+    <std::unordered_multimap<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_const_conversion_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_const_conversion_neg.cc
new file mode 100644 (file)
index 0000000..62c0280
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_const_conversion
+    <std::unordered_multimap<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_assignment_neg.cc
new file mode 100644 (file)
index 0000000..9ac5b35
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_assignment
+    <std::unordered_multimap<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_construction_neg.cc
new file mode 100644 (file)
index 0000000..4140272
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_construction
+    <std::unordered_multimap<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_assignment_neg.cc
new file mode 100644 (file)
index 0000000..32c847c
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_assignment
+    <std::unordered_multimap<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_construction_neg.cc
new file mode 100644 (file)
index 0000000..124b9ec
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_construction
+    <std::unordered_multimap<int, int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 25967980dc9de07c2b95d7dfc159000baff4873b..7fbc453f0452cc940db788bc863e9df9ee207c21 100644 (file)
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.max_load_factor(-1.0f);
 }
 
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_arrow_operator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_arrow_operator_neg.cc
new file mode 100644 (file)
index 0000000..1677b20
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_arrow_operator
+    <std::unordered_multiset<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_const_conversion_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_const_conversion_neg.cc
new file mode 100644 (file)
index 0000000..0d64a41
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_const_conversion
+    <std::unordered_multiset<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_assignment_neg.cc
new file mode 100644 (file)
index 0000000..b0d7b9f
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_assignment
+    <std::unordered_multiset<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_construction_neg.cc
new file mode 100644 (file)
index 0000000..fa9c5ee
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_construction
+    <std::unordered_multiset<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_assignment_neg.cc
new file mode 100644 (file)
index 0000000..b25fedc
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_assignment
+    <std::unordered_multiset<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_construction_neg.cc
new file mode 100644 (file)
index 0000000..8b855b2
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_construction
+    <std::unordered_multiset<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_arrow_operator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_arrow_operator_neg.cc
new file mode 100644 (file)
index 0000000..f62ed6b
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_arrow_operator
+    <std::unordered_set<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_const_conversion_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_const_conversion_neg.cc
new file mode 100644 (file)
index 0000000..839f9ae
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_const_conversion
+    <std::unordered_set<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_assignment_neg.cc
new file mode 100644 (file)
index 0000000..377019f
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_assignment
+    <std::unordered_set<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_construction_neg.cc
new file mode 100644 (file)
index 0000000..1f7e6dd
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_copy_construction
+    <std::unordered_set<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_assignment_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_assignment_neg.cc
new file mode 100644 (file)
index 0000000..d16a154
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_assignment
+    <std::unordered_set<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_construction_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_construction_neg.cc
new file mode 100644 (file)
index 0000000..d878abf
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do run { target c++11 xfail *-*-* } }
+// { dg-require-debug-mode "" }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+  __gnu_test::invalid_local_iterator_move_construction
+    <std::unordered_set<int>>();
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index d01ee827c48227c71e1a3d6731d5e0cafe459a9a..785aeb41f6d1044ca313a62992c5d76c55254482 100644 (file)
@@ -65,28 +65,36 @@ namespace __gnu_test
   template<typename _Tp>
     struct KeyExtractor
     {
-      static _Tp get_key(const _Tp& val)
+      static const _Tp& get_key(const _Tp& val)
       { return val; }
     };
 
   template<typename _Tp1, typename _Tp2>
-    struct KeyExtractor<std::pair<const _Tp1, _Tp2>>
+    struct KeyExtractor<std::pair<_Tp1, _Tp2>>
     {
-      static _Tp1 get_key(const std::pair<const _Tp1, _Tp2>& val)
+      static const _Tp1& get_key(const std::pair<_Tp1, _Tp2>& val)
       { return val.first; }
     };
 
   template<typename _Tp>
-    void use_erased_local_iterator()
+    void fill_container(_Tp& c)
     {
       typedef _Tp cont_type;
       typedef typename cont_type::value_type cont_val_type;
       typedef typename CopyableValueType<cont_val_type>::value_type val_type;
       generate_unique<val_type> gu;
 
-      cont_type c;
       for (size_t i = 0; i != 5; ++i)
        c.insert(gu.build());
+    }
+
+  template<typename _Tp>
+    void use_erased_local_iterator()
+    {
+      typedef _Tp cont_type;
+      typedef typename cont_type::value_type cont_val_type;
+      cont_type c;
+      fill_container(c);
 
       typename cont_type::local_iterator it, end;
       for (size_t i = 0; i != c.bucket_count(); ++i)
@@ -96,22 +104,18 @@ namespace __gnu_test
        if (it != end)
          break;
       }
-      typename cont_type::key_type key = KeyExtractor<cont_val_type>::get_key(*it);
+
+      const auto& key = KeyExtractor<cont_val_type>::get_key(*it);
       c.erase(key);
       VERIFY( it != end );
   }
 
   template<typename _Tp>
-    void use_invalid_local_iterator()
+    typename _Tp::local_iterator
+    fill_and_get_local_iterator(_Tp& c)
     {
       typedef _Tp cont_type;
-      typedef typename cont_type::value_type cont_val_type;
-      typedef typename CopyableValueType<cont_val_type>::value_type val_type;
-      generate_unique<val_type> gu;
-
-      cont_type c;
-      for (size_t i = 0; i != 5; ++i)
-       c.insert(gu.build());
+      fill_container(c);
 
       typename cont_type::local_iterator it;
       for (size_t i = 0; i != c.bucket_count(); ++i)
@@ -120,22 +124,107 @@ namespace __gnu_test
        if (it != c.end(i))
          break;
       }
-      cont_val_type val = *it;
+
+      return it;
+    }
+
+  template<typename _Tp>
+    void use_invalid_local_iterator()
+    {
+      typedef _Tp cont_type;
+      cont_type c;
+      auto it = fill_and_get_local_iterator(c);
+
+      const auto& val = *it;
       c.clear();
       VERIFY( *it == val );
     }
 
   template<typename _Tp>
-    void invalid_local_iterator_pre_increment()
+    void invalid_local_iterator_arrow_operator()
     {
       typedef _Tp cont_type;
-      typedef typename cont_type::value_type cont_val_type;
-      typedef typename CopyableValueType<cont_val_type>::value_type val_type;
-      generate_unique<val_type> gu;
+      cont_type c;
+      auto it = fill_and_get_local_iterator(c);
+
+      const auto& val = *it;
+      c.clear();
+      VERIFY( *it.operator->() == val );
+    }
 
+  template<typename _Tp>
+    void invalid_local_iterator_copy_construction()
+    {
+      typedef _Tp cont_type;
       cont_type c;
-      for (size_t i = 0; i != 5; ++i)
-       c.insert(gu.build());
+      auto it = fill_and_get_local_iterator(c);
+
+      const auto& val = *it;
+      c.clear();
+      typename cont_type::local_iterator lit(it);
+      VERIFY( *lit == val );
+    }
+
+  template<typename _Tp>
+    void invalid_local_iterator_move_construction()
+    {
+      typedef _Tp cont_type;
+      cont_type c;
+      auto it = fill_and_get_local_iterator(c);
+
+      const auto& val = *it;
+      c.clear();
+      typename cont_type::local_iterator lit(std::move(it));
+      VERIFY( *lit == val );
+    }
+
+  template<typename _Tp>
+    void invalid_local_iterator_copy_assignment()
+    {
+      typedef _Tp cont_type;
+      cont_type c;
+      auto it = fill_and_get_local_iterator(c);
+
+      const auto& val = *it;
+      c.clear();
+      typename cont_type::local_iterator lit;
+      lit = it;
+      VERIFY( *lit == val );
+    }
+
+  template<typename _Tp>
+    void invalid_local_iterator_move_assignment()
+    {
+      typedef _Tp cont_type;
+      cont_type c;
+      auto it = fill_and_get_local_iterator(c);
+
+      const auto& val = *it;
+      c.clear();
+      typename cont_type::local_iterator lit;
+      lit = std::move(it);
+      VERIFY( *lit == val );
+    }
+
+  template<typename _Tp>
+    void invalid_local_iterator_const_conversion()
+    {
+      typedef _Tp cont_type;
+      cont_type c;
+      auto it = fill_and_get_local_iterator(c);
+
+      const auto& val = *it;
+      c.clear();
+      typename cont_type::const_local_iterator clit(it);
+      VERIFY( *clit == val );
+    }
+
+  template<typename _Tp>
+    void invalid_local_iterator_pre_increment()
+    {
+      typedef _Tp cont_type;
+      cont_type c;
+      fill_container(c);
 
       auto lit = c.begin(0);
       for (size_t i = 0; i != 6; ++i)
@@ -146,13 +235,8 @@ namespace __gnu_test
     void invalid_local_iterator_post_increment()
     {
       typedef _Tp cont_type;
-      typedef typename cont_type::value_type cont_val_type;
-      typedef typename CopyableValueType<cont_val_type>::value_type val_type;
-      generate_unique<val_type> gu;
-
       cont_type c;
-      for (size_t i = 0; i != 5; ++i)
-       c.insert(gu.build());
+      fill_container(c);
 
       auto lit = c.begin(0);
       for (size_t i = 0; i != 6; ++i)
@@ -163,13 +247,8 @@ namespace __gnu_test
     void invalid_local_iterator_compare()
     {
       typedef _Tp cont_type;
-      typedef typename cont_type::value_type cont_val_type;
-      typedef typename CopyableValueType<cont_val_type>::value_type val_type;
-      generate_unique<val_type> gu;
-
       cont_type c;
-      for (size_t i = 0; i != 5; ++i)
-       c.insert(gu.build());
+      fill_container(c);
 
       typename cont_type::local_iterator it1, it2;
       size_t i;
@@ -194,13 +273,8 @@ namespace __gnu_test
     void invalid_local_iterator_range()
     {
       typedef _Tp cont_type;
-      typedef typename cont_type::value_type cont_val_type;
-      typedef typename CopyableValueType<cont_val_type>::value_type val_type;
-      generate_unique<val_type> gu;
-
       cont_type c;
-      for (size_t i = 0; i != 5; ++i)
-       c.insert(gu.build());
+      fill_container(c);
 
       typename cont_type::local_iterator it, end;
       for (size_t i = 0; i != c.bucket_count(); ++i)