#define _GLIBCXX_DEBUG 1 #include <unordered_set> int main() { std::unordered_set<int>::iterator it{}; it == it; } This aborts at runtime: /home/jwakely/gcc/11/include/c++/11.0.0/debug/safe_iterator.h:461: In function: bool __gnu_debug::operator==(const _Self&, const _Self&) Error: attempt to compare a singular iterator to a singular iterator. Objects involved in the operation: iterator "__lhs" @ 0x0x7ffc0e6d5940 { type = std::__detail::_Node_iterator<int, true, false> (mutable iterator); state = singular; } iterator "__rhs" @ 0x0x7ffc0e6d5940 { type = std::__detail::_Node_iterator<int, true, false> (mutable iterator); state = singular; } Aborted (core dumped) It seems that https://wg21.link/n3644 was not implemented for the debug mode iterators.
This bug looks like a duplicate of bug 70303. The asserts presented there should be used on random-access iterators (vector, deque) to test if N3644 is implement.
This was already fixed on master by r11-6682 05a30af3f237984b4dcf1dbbc17fdac583c46506
(In reply to Jonathan Wakely from comment #2) > This was already fixed on master by r11-6682 > 05a30af3f237984b4dcf1dbbc17fdac583c46506 Yes, that patch mostly fixes bug 70303, too. With that patch, the asserts presented in bug 70303 pass for vector<int>::iterator but not for deque<int>::iterator.
Fully fixed