Re: Linking Program with Lib That Uses -fwrapv or '-fno-strict-overflow'

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

 



On Tue, Jul 26, 2011 at 1:49 AM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
> Jeffrey Walton <noloader@xxxxxxxxx> writes:
>
>> A simplified example (I know you gave a previous work around) assuming
>> 32 bit ints:
>>
>> // liboverflow, compiled with -fwrapv
>> int my_abs(int x, int* r)
>> {
>>     int y = abs(x);
>>     if (y < 0)
>>         return 0;
>>
>>     *r = y;
>>     return 1;
>> }
>>
>> // myprogram, compiled with -O2 and linked against liboverflow
>> int x = 0x80000000, r = 0;
>> if(my_abs(x, &r))
>>     printf(...)
>>
>> Will the resulting program enjoy O2 and/or produce incorrect results?
>
> If you are asking whether this program has signed overflow problems, the
> answer is no.  Compiling liboverflow with -fwrapv does not affect
> myprogram.  Similarly, compiling myprogram without -fwrapv does not
> affect liboverflow.
As always, thank you very much.

Jeff



[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