https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- Why does your patch need to touch operator* or operator-> for any of the iterators? For any dereferenceable iterator the cast should be valid, so if you're seeing invalid casts it suggests that you are dereferencing invalid iterators.