https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124210
Bug ID: 124210
Summary: unordered local iterators should not be comparable to
unordered iterators
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include <unordered_set>
int main()
{
std::unordered_set<int> s{1,2,3,4,5,6};
auto lb = s.begin(0);
auto b = s.begin();
return lb == b;
}
This is not required to compile by the standard, and I don't think it's a
useful extension. We should make it ill-formed, so that users don't
accidentally rely on this.
I think the __gnu_debug::_Safe_unordered_container::_M_invalidate_local_if
function currently relies on this comparison, but we could fix that (e.g. by
comparing addressof(*it) instead of comparing iterators, or by adding a named
comparison function such as _Node_iterator_base::_M_equal_to to use instead of
operator==).