[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] intprops: add WRAPV and const flavors for GCC 5

From: Pádraig Brady
Subject: Re: [PATCH] intprops: add WRAPV and const flavors for GCC 5
Date: Fri, 18 Dec 2015 03:29:15 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 17/12/15 21:02, Paul Eggert wrote:
> On 12/17/2015 06:19 AM, Pádraig Brady wrote:
>> -     long int result = INT_MULTIPLY_WRAPV (a, b);
>> +     long int result = a * b;
> This doesn't look right, because a * b could overflow which would lead 
> to undefined behavior. INT_MULTIPLY_WRAPV does not rely on undefined 
> behavior due to integer overflow, which is the point of that example.

Right. The issue I have with the example is that INT_MULTIPLY_WRAPV()
takes 3 arguments, while only 2 are provided.

> I tracked this down to what appears to be a compiler bug in GCC, filed a 
> bug report with the GCC folks (GCC bug 68971), and installed the 
> attached patch instead.

Right. I see the undefined code is never called or added to the translation 
In case gcc decides to continue to warn in this case, I suppose we could avoid
the undefined code by promoting to a wider type and explicitly truncating
the result (though that might need __int128 if available for your new 64 bit 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]