This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/46424] Iterators being improperly invalidated
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Nov 2010 17:13:21 +0000
- Subject: [Bug libstdc++/46424] Iterators being improperly invalidated
- Auto-submitted: auto-generated
- References: <bug-46424-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46424
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-11 17:13:20 UTC ---
(In reply to comment #5)
>
> Maybe I'm misinterpreting the standard, but in 23.2.1, it states:
>
> "The insert members shall not affect the validity of iterators and references
> to the container, and the erase members shall invalidate only iterators and
> references to the erased elements."
>
> Since out is not an iterator to a member of toDo, shouldn't it remain valid
> through this operation?
Are you having a laugh?
in networkgraph.cpp, line 84
std::set<PublicKey>::iterator out = toDo.begin();
then on line 90 you assign another iterator from toDo to out
What makes you think out is not an iterator to a member of toDo?
then on line 98 you do:
toDo.erase( *out );
that erases *out from the set, which invalidates iterators to the erased
element, specifially it invalidates out.