This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/46424] Iterators being improperly invalidated


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]