Peter Maydell <peter.mayd...@linaro.org> writes:

> On 7 April 2014 15:25, Richard Henderson <r...@twiddle.net> wrote:
>> On 04/06/2014 08:27 AM, Peter Maydell wrote:
>>> (if C compilers had a "behave
>>> like a sane 2s complement system for signed arithmetic"
>>> option I'd be advocating for us using it...)
>>
>> -fwrapv.
>
> Well, we should use that then :-)

I share your distaste for compilers being perfectly capable to recognize
undefined behavior so they can "optimize" working programs into slightly
faster broken programs, yet unable to warn me about the very same
undefined behavior they so eagerly exploit.

-fwrapv is known to be buggy in gcc 4.1.  Do we care?

It bit the kernel a couple of years ago, and they replaced -fwrapv by
-fno-strict-overflow.

Commit introducing -fwrapv:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=68df3755e383e6fecf2354a67b08f92f18536594

Commit moving to -fno-strict-overflow:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=a137802ee839ace40079bebde24cfb416f73208a

Blog post comparing the two options:
http://www.airs.com/blog/archives/120

Reply via email to