https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61347
François Dumont <fdumont at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fdumont at gcc dot gnu.org --- Comment #2 from François Dumont <fdumont at gcc dot gnu.org> --- If you specialize std::distance for list iterators please do not forget to do so also in debug mode otherwise operation will go back to O(N) in this mode. Of course make sure that the ++l.end() == l.begin() won't be run on debug iterators. It won't appreciate increment past the end iterator.