https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112477
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Francois Dumont <fdum...@gcc.gnu.org>: https://gcc.gnu.org/g:ffc5684a4d3d3c457e5d311e7088f3487cf5083e commit r13-8212-gffc5684a4d3d3c457e5d311e7088f3487cf5083e Author: François Dumont <fdum...@gcc.gnu.org> Date: Wed Jan 10 19:06:48 2024 +0100 libstdc++: [_GLIBCXX_DEBUG] Fix assignment of value-initialized iterator [PR112477] Now that _M_Detach do not reset iterator _M_version value we need to reset it when the iterator is attached to a new sequence. Even if this sequence is null like when assigning a value-initialized iterator. In this case _M_version shall be reset to 0. libstdc++-v3/ChangeLog: PR libstdc++/112477 * src/c++11/debug.cc (_Safe_iterator_base::_M_attach): Reset _M_version to 0 if attaching to null sequence. (_Safe_iterator_base::_M_attach_single): Likewise. (_Safe_local_iterator_base::_M_attach): Likewise. (_Safe_local_iterator_base::_M_attach_single): Likewise. * testsuite/23_containers/map/debug/112477.cc: New test case. Reviewed-by: Jonathan Wakely <jwak...@redhat.com>