http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46424
Summary: Iterators being improperly invalidated Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: shadow7...@gmail.com Created attachment 22371 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22371 Snippet of my code which crashes I actually have a terribly difficult time explaining the bug I am encountering, but it seems that when I call erase on the dereferenced value of a set iterator from another set, it causes the iterator to be invalidated. I was able to work around this bug by moving the call to erase until after the iterator is used. I have attached the code in question. The problem is in the function NetworkGraph::bestRoute. It is commented accordingly. Fair warning, the code is a slow, confusing implementation of a graph and (a slightly tweaked version) of Dijkstra's algorithm. The code is also basically uncommented, sorry. I also basically took the code directly out of the project I am working on right now, so it requires UnitTest++ and crypto++ to compile, but this does not affect the code in question. It is also somewhat possible that what I think is an error is actually intended, but if I remember correctly, iterators are supposed to remain valid so long as the object they point to is not deleted. There is also chance that the problem is not with the iterators, but instead with the implementation of set::erase. Regardless, it seems to me like something is aloof.