https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124210

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I tested this change:

--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -1147,6 +1147,13 @@ namespace __detail
     public:
       size_t
       _M_get_bucket() const { return _M_bucket; }  // for debug mode
+
+      bool operator==(const _Local_iterator_base& __it) const
+      {
+       return static_cast<const __base_node_iter&>(*this)
+              == static_cast<const __base_node_iter&>(__it);
+      }
+      bool operator==(const __base_node_iter&) const = delete;
     };

   // Uninitialized storage for a _Hash object in a local iterator.
@@ -1243,6 +1250,13 @@ namespace __detail
     public:
       size_t
       _M_get_bucket() const { return _M_bucket; }  // for debug mode
+
+      bool operator==(const _Local_iterator_base& __it) const
+      {
+       return static_cast<const __node_iter_base&>(*this)
+              == static_cast<const __node_iter_base&>(__it);
+      }
+      bool operator==(const __node_iter_base&) const = delete;
     };

   /// local iterators


(Aside: Why is it __base_node_iter in one specialization and __node_iter_base
in the other?!)

Only debug mode tests failed, which means we have no tests verifying that local
iterators can be compared to non-local iterators, so this doesn't seem to be an
intentionally supported extension. It's just an accidental side effect of using
the same _Node_iterator_base base class for all iterators.

FAIL: 23_containers/unordered_map/debug/invalidation/erase_if.cc  -std=gnu++20
(test for excess errors)
UNRESOLVED: 23_containers/unordered_map/debug/invalidation/erase_if.cc 
-std=gnu++20 compilation failed to produce executable
FAIL: 23_containers/unordered_map/requirements/debug_container.cc  -std=gnu++20
(test for excess errors)

Reply via email to