https://gcc.gnu.org/g:9662c9526f8c60a192b1358671463402829279d6

commit r16-29-g9662c9526f8c60a192b1358671463402829279d6
Author: François Dumont <frs.dum...@gmail.com>
Date:   Tue Apr 8 19:35:28 2025 +0200

    libstdc++: Add _GLIBCXX_DEBUG checks on unordered container local_iterator
    
    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 <jwak...@redhat.com>

Diff:
---
 .../invalid_local_iterator_arrow_operator_neg.cc   |  17 +++
 .../invalid_local_iterator_const_conversion_neg.cc |  17 +++
 .../invalid_local_iterator_copy_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_copy_construction_neg.cc |  17 +++
 .../invalid_local_iterator_move_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_move_construction_neg.cc |  17 +++
 .../unordered_map/debug/max_load_factor_neg.cc     |   2 +-
 .../unordered_multimap/debug/begin2_neg.cc         |   4 +-
 .../unordered_multimap/debug/bucket_size_neg.cc    |   2 +-
 .../unordered_multimap/debug/cbegin_neg.cc         |   2 +-
 .../unordered_multimap/debug/cend_neg.cc           |   2 +-
 .../unordered_multimap/debug/end1_neg.cc           |   2 +-
 .../unordered_multimap/debug/end2_neg.cc           |   4 +-
 .../invalid_local_iterator_arrow_operator_neg.cc   |  17 +++
 .../invalid_local_iterator_const_conversion_neg.cc |  17 +++
 .../invalid_local_iterator_copy_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_copy_construction_neg.cc |  17 +++
 .../invalid_local_iterator_move_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_move_construction_neg.cc |  17 +++
 .../debug/max_load_factor_neg.cc                   |   2 +-
 .../invalid_local_iterator_arrow_operator_neg.cc   |  17 +++
 .../invalid_local_iterator_const_conversion_neg.cc |  17 +++
 .../invalid_local_iterator_copy_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_copy_construction_neg.cc |  17 +++
 .../invalid_local_iterator_move_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_move_construction_neg.cc |  17 +++
 .../invalid_local_iterator_arrow_operator_neg.cc   |  17 +++
 .../invalid_local_iterator_const_conversion_neg.cc |  17 +++
 .../invalid_local_iterator_copy_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_copy_construction_neg.cc |  17 +++
 .../invalid_local_iterator_move_assignment_neg.cc  |  17 +++
 ...invalid_local_iterator_move_construction_neg.cc |  17 +++
 .../testsuite/util/debug/unordered_checks.h        | 152 +++++++++++++++------
 33 files changed, 531 insertions(+), 49 deletions(-)

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
index 000000000000..09870a76b996
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_arrow_operator_neg.cc
@@ -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
index 000000000000..7bfe3a8d76f5
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_const_conversion_neg.cc
@@ -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
index 000000000000..d3b671b14cf1
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_assignment_neg.cc
@@ -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
index 000000000000..d6096718aca1
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_construction_neg.cc
@@ -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
index 000000000000..8d2ed6bf2152
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_assignment_neg.cc
@@ -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
index 000000000000..dd9b7dc29e7c
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_construction_neg.cc
@@ -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;
+}
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc
 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc
index 7fbc453f0452..25967980dc9d 100644
--- 
a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_multimap<int, int> um;
+  std::unordered_map<int, int> um;
   um.max_load_factor(-1.0f);
 }
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc
index ff787cf6f4a9..b2d67fbaa002 100644
--- 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc
@@ -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());
 }
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc
 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc
index b5ddb18af8f0..4d5cb846a64c 100644
--- 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.bucket_size(um.bucket_count());
 }
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc
index 5ba1da56aa54..654d4091fb36 100644
--- 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.cbegin(um.bucket_count());
 }
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc
index 031be37e0e7b..f7149d40f51e 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.cend(um.bucket_count());
 }
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc
index d412fcf9e4e7..fd0f981b4e45 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc
@@ -22,7 +22,7 @@
 
 void test01()
 {
-  std::unordered_map<int, int> um;
+  std::unordered_multimap<int, int> um;
   um.end(um.bucket_count());
 }
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc
index 0115351df944..0c3f86c43596 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc
@@ -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
index 000000000000..8b2302010d95
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_arrow_operator_neg.cc
@@ -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
index 000000000000..62c0280c201b
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_const_conversion_neg.cc
@@ -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
index 000000000000..9ac5b35045a0
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_assignment_neg.cc
@@ -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
index 000000000000..41402720ab6a
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_construction_neg.cc
@@ -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
index 000000000000..32c847c9b2f2
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_assignment_neg.cc
@@ -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
index 000000000000..124b9ec01779
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_construction_neg.cc
@@ -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;
+}
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc
 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc
index 25967980dc9d..7fbc453f0452 100644
--- 
a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc
@@ -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
index 000000000000..1677b2022635
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_arrow_operator_neg.cc
@@ -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
index 000000000000..0d64a4129cd1
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_const_conversion_neg.cc
@@ -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
index 000000000000..b0d7b9f47987
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_assignment_neg.cc
@@ -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
index 000000000000..fa9c5ee26d48
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_construction_neg.cc
@@ -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
index 000000000000..b25fedc6b2ef
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_assignment_neg.cc
@@ -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
index 000000000000..8b855b26cd20
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_construction_neg.cc
@@ -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
index 000000000000..f62ed6bd453d
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_arrow_operator_neg.cc
@@ -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
index 000000000000..839f9aec0940
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_const_conversion_neg.cc
@@ -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
index 000000000000..377019f8a352
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_assignment_neg.cc
@@ -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
index 000000000000..1f7e6ddb17bf
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_construction_neg.cc
@@ -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
index 000000000000..d16a154de003
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_assignment_neg.cc
@@ -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
index 000000000000..d878abf37465
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_construction_neg.cc
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/util/debug/unordered_checks.h 
b/libstdc++-v3/testsuite/util/debug/unordered_checks.h
index d01ee827c482..785aeb41f6d1 100644
--- a/libstdc++-v3/testsuite/util/debug/unordered_checks.h
+++ b/libstdc++-v3/testsuite/util/debug/unordered_checks.h
@@ -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)

Reply via email to