[llvm] r178166 - Avoid undefined behavior from passing a std::vector's own contents

Howard Hinnant hhinnant at apple.com
Wed Mar 27 12:16:11 PDT 2013


On Mar 27, 2013, at 2:44 PM, Dan Gohman <dan433584 at gmail.com> wrote:

> Author: djg
> Date: Wed Mar 27 13:44:56 2013
> New Revision: 178166
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=178166&view=rev
> Log:
> Avoid undefined behavior from passing a std::vector's own contents
> in as an argument to push_back.

The original code is not undefined behavior.

Howard

> 
> Modified:
>    llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
> 
> Modified: llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenSchedule.cpp?rev=178166&r1=178165&r2=178166&view=diff
> ==============================================================================
> --- llvm/trunk/utils/TableGen/CodeGenSchedule.cpp (original)
> +++ llvm/trunk/utils/TableGen/CodeGenSchedule.cpp Wed Mar 27 13:44:56 2013
> @@ -1105,7 +1105,9 @@ void PredTransitions::getIntersectingVar
>       // 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);
>     }
>   }
> }
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list