[LLVMbugs] [Bug 20520] std::list<>::remove_if() visits elements multiple times

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 4 10:32:40 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20520

Marshall Clow (home) <mclow.lists at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Marshall Clow (home) <mclow.lists at gmail.com> ---
After the call to erase, we know that either (a) we're at the end of the list,
or (b) we're looking at an element that the predicate has returned "false" for.
So we can just increment the iterator, and move on.

             __i = erase(__i, __j);
+            if (__i != __e)
+                __i = _VSTD::next(__i);

I don't see that forward_list has this problem, because the code is somewhat
different.

Committed revision 214736 to fix this (and add tests).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140804/e7503d56/attachment.html>


More information about the llvm-bugs mailing list