[llvm-commits] [llvm] r83391 - /llvm/trunk/lib/Support/Triple.cpp
Chris Lattner
clattner at apple.com
Tue Oct 6 13:23:23 PDT 2009
On Oct 6, 2009, at 10:25 AM, Jeffrey Yasskin wrote:
> Author: jyasskin
> Date: Tue Oct 6 12:25:50 2009
> New Revision: 83391
>
> URL: http://llvm.org/viewvc/llvm-project?rev=83391&view=rev
> Log:
> Fix PR5112, a miscompilation on gcc-4.0.3. Patch by Collin Winter!
>
> Modified:
> llvm/trunk/lib/Support/Triple.cpp
>
> Modified: llvm/trunk/lib/Support/Triple.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=83391&r1=83390&r2=83391&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Support/Triple.cpp (original)
> +++ llvm/trunk/lib/Support/Triple.cpp Tue Oct 6 12:25:50 2009
> @@ -390,7 +390,10 @@
> }
>
> void Triple::setArchName(const StringRef &Str) {
> - setTriple(Str + "-" + getVendorName() + "-" +
> getOSAndEnvironmentName());
> + // Work around a miscompilation bug in gcc 4.0.3.
> + Twine a = getVendorName() + "-" + getOSAndEnvironmentName();
> + Twine b = Str + "-" + a;
> + setTriple(b);
> }
Jeffrey, I don't think this patch is safe. Twines are constructed
based on temporaries. I think taht the temporary returned by
getVendorName() is destroyed at the ";" and the twine refers to the
dangling pointer. CAn you just build up a temporary std::string
instead?
-Chris
More information about the llvm-commits
mailing list