https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92472
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to David Binderman from comment #7) > (In reply to Jonathan Wakely from comment #6) > > Those parameter can NOT be const, because *__b1 and *__b2 will not > > compile if they're const, because operator* is not const. > > My understanding of C++, frayed somewhat since 1988, is that operator * > being const is a different language feature to parameters being const. The function looks like this: friend bool operator<(const _UnguardedIterator<_RAIter, _Compare>& __bi1, const _UnguardedIterator<_RAIter, _Compare>& __bi2) { // Normal compare. return (__bi1.__comp)(*__bi1, *__bi2); } i.e. it uses *__b1 which uses _UnguardedIterator::operator* If you change __b1 to be const, you can't call non-const member functions on that object, including _UnguardedIterator::operator* > Any guidance on fixing this problem, if it is a problem at all, > would be most welcome. It's not a problem. The code should be left alone to die in peace.