https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89608
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2019-03-06 CC| |fdumont at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- François, could you take a look please? The standard says: > The insert and emplace members shall not affect the validity of iterators if > (N+n) <= z * B, where N is the number of elements in the container prior to > the insert operation, n is the number of elements inserted, B is the > container’s bucket count, and z is the container’s maximum load factor. The insertion does rehash, so should invalidate the iterators. It looks like the _M_check_rehashed function only invalidates local iterators, despite the order of elements changing.