From 08d5fd9099d1106eb296c504ea40375a031e0eb0 Mon Sep 17 00:00:00 2001 From: David Greene Date: Mon, 17 Dec 2007 17:39:51 +0000 Subject: [PATCH] Fix GLIBCXX_DEBUG errors. Erase invalidates std::vector iterators passed the erased element. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45099 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/DCE.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 163c2b00611..9cad2362954 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -109,11 +109,10 @@ bool DCE::runOnFunction(Function &F) { I->eraseFromParent(); // Remove the instruction from the worklist if it still exists in it. - for (std::vector::iterator WI = WorkList.begin(), - E = WorkList.end(); WI != E; ++WI) + for (std::vector::iterator WI = WorkList.begin(); + WI != WorkList.end(); ++WI) if (*WI == I) { - WorkList.erase(WI); - --E; + WI = WorkList.erase(WI); --WI; }