This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/23633] map::insert() invalidates reverse_iterators
- From: "chris at bubblescope dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Aug 2005 20:16:03 -0000
- Subject: [Bug libstdc++/23633] map::insert() invalidates reverse_iterators
- References: <20050830125045.23633.relf@os2.ru>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From chris at bubblescope dot net 2005-08-30 20:16 -------
Just so we are 100% clear on what is occuring (I realise it might not be obvious from my message)
M.rbegin() returns an iterator i = std::reverse_iterator(M.end());
*i therefore returns *--(M.end()), which at first is the same as M.begin().
After we stick some more stuff into the container, then *i (which is still equal *--(M.end())) becomes
something different, as more stuff has been pushed into the container.
This is exactly what the standard requires we do, it's just unfortunatly that reverse_iterator is a little fragile
in the presence of changing containers.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23633