From 38a723830cee87aac2141e5c8435fce4d81406af Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 27 Mar 2013 18:44:56 +0000 Subject: [PATCH] Avoid undefined behavior from passing a std::vector's own contents in as an argument to push_back. llvm-svn: 178166 --- llvm/utils/TableGen/CodeGenSchedule.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp index 818fce2048c5..886c4c639448 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.cpp +++ b/llvm/utils/TableGen/CodeGenSchedule.cpp @@ -1105,7 +1105,9 @@ void PredTransitions::getIntersectingVariants( // Push another copy of the current transition for more variants. Variant.TransVecIdx = TransVec.size(); IntersectingVariants.push_back(Variant); - TransVec.push_back(TransVec[TransIdx]); + + PredTransition Trans = TransVec[TransIdx]; + TransVec.push_back(Trans); } } }