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

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 11 09:30:00 GMT 2010


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46424

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-11 09:30:40 UTC ---
(In reply to comment #1)
> I forgot to mention one thing.  The code that seems to acting suspisciously is
> this bit:
> 
> toDo.erase( *out );  //Putting this code here instead of the end breaks this
> code.

This invalidates out.

> std::map<PublicKey, std::set<PublicKey> >::const_iterator giter = graph.find(
> *out );

And now you dereference an invalid iterator.

This looks clearly broken to me, but I have only looked briefly. Please follow
GCC's bug reporting guidelines and provide a self-contained testcase without
other libraries - I'm not going to download and install them.  Provide
preprocessed source if you really can't remove them.

Please also try compiling with -D_GLIBCXX_DEBUG, or changing the type of toDo
to __gnu_debug::set<PublicKey>, after including <debug/set>, which might tell
you the problem.



More information about the Gcc-bugs mailing list