https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78134
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- It's not returning S::const_iterator, if it was the assertion would pass because S::iterator and S::const_iterator are the same type. The problem is that it's returning _Rb_tree::iterator rather than wrapping it in a set::iterator.