[llvm-commits] [llvm] r83391 - /llvm/trunk/lib/Support/Triple.cpp

Jeffrey Yasskin jyasskin at google.com
Tue Oct 6 14:01:47 PDT 2009


On Tue, Oct 6, 2009 at 1:23 PM, Chris Lattner <clattner at apple.com> wrote:
>
> 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?

Oops. SmallString<64> it is. Collin, could you check that this still
works around the gcc-4.0.3 bug?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_triple_again.patch
Type: application/octet-stream
Size: 877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20091006/b4802aff/attachment.obj>


More information about the llvm-commits mailing list