https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113851
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Ugh. The problem is: 1272 | if (__iter == _M_bad_char.end()) which does ADL for operator== In general there's no way to fix this, we *must* do ADL for iterator equality comparisons (and other operators like operator* and operator++) because they might be named member functions, or they might be built-in operators if the iterator is a pointer. In this case we *must* do ADL for operator== because it's a hidden friend so there's no other way to find it. And if you can't test iterators for equality, you can't really do anything useful with them (except for output iterators).