Re: question about -Werror=strict-overflow

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

 



2011/5/17 Ian Lance Taylor <iant@xxxxxxxxxx>:
> JÄdrzej Dudkiewicz <jedrzej.dudkiewicz@xxxxxxxxx> writes:
>
>> I see the following warning:
>>
>> "assuming signed overflow does not occur when simplifying conditional
>> to constant"
>>
>> pointing to a line containing:
>>
>> if (iRv == SSLSOCK_S_SUCCEED)
>>
>> where:
>>
>> typedef signed int TInt32;
>> TInt32 iRv;
>> #define SSLSOCK_S_SUCCEED 0
>>
>> Is there any chance for overflow?
>
> What that warning means is that gcc has somehow determined that that
> comparison is either always true or always false. ÂThat determination
> was made under the assumption that no signed overflow occurred. ÂSo the
> issue is not on the line you have shown us; it's on the lines which set
> iRv.

Thank you very much for your answer.

It's very strange - in whole function (300 lines, yay), this variable is used:
1) to store return values from different functions, all of them
returning signed integers
2) for comparison with different values defined in a manner similar to
SSLSOCK_S_SUCCED mentioned above.

There are no arithmetic, logical or bit operations involving this
variable. It's completely beyond me, why would gcc change this to a
constant.

Or maybe gcc based it's assumption on expressions that are executed
inside this "if"? Maybe with something like:

int var = ??;
if (var)
{
    if (var)
    { ... } else { ...}
}

first check can be completely removed? But even then - assigned overflow?
-- 
JÄdrzej Dudkiewicz

I really hate this damn machine, I wish that they would sell it.
It never does just what I want, but only what I tell it.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux