[LLVMdev] SmallPtrSet Iterator Behavior
David Greene
dag at cray.com
Tue Dec 4 09:15:32 PST 2007
What are the rules regarding iterator stability for SmallPtrSet?
I'm running into a problem where erasing an element seems
to invalidate iterators that are not pointing at the erased element.
Specifically, the set is in small mode, I advance an iterator to the last
element in the set (not end(), but one before) and then erase the
second-to-last element. I understand that the last element will replace
the element at the erased location and I would think that the advanced
iterator would now point to end(). In other words, the advanced iterator
will "miss" the last element. But that doesn't seem to be the case
when I do an equality check with end(). It's pointing somewhere not
good because I try to dereference it and I get garbage.
Thanks for any help.
-Dave
More information about the llvm-dev
mailing list