autoconf-patches
[Top][All Lists]
Advanced

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

RE: changing "configure" to default to "gcc -g -O2 -fwrapv ..."


From: Dave Korn
Subject: RE: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Sat, 30 Dec 2006 20:02:04 -0000

On 30 December 2006 11:49, Robert Dewar wrote:

> Paul Eggert wrote:
>>>> Nor would I relish the prospect of keeping wrapv assumptions out of
>>>> GCC as other developers make further contributions, as the wrapv
>>>> assumption is so natural and pervasive.
>>> It's neither natural not pervasive to me!  I would never write code
>>> that way
>> 
>> That's great, but GCC has had many other hands stirring the pot.
>> I daresay a careful scan would come up with many other examples of
>> undefined behavior due to signed integer overflow.  (No doubt
>> you'll be appalled by them as well, but there they are.)
> 
> Not so appalling really, given that relying on wrapping is as
> has been pointed out in this thread, the most natural and
> convenient way of testing for overflow. It is really *quite*
> difficult to test for overflow while avoiding overflow, and
> this is something that is probably not in the lexicon of
> many C programmers.

  Maybe the answer (as far as autoconf goes) is that autoconf tests should be
compiled at -O0.  They are trying to determine the underlying machine
behaviour; -O0 makes gcc more like the glorified-assembler model of a
compiler.  Which is probably what we want; the code to actually execute on the
target, not for the compiler to deduce what it would do if it did run and
maybe get it wrong.

  (Maybe they could be compiled at -O0 *and* at -O2, and the results compared,
to infer overflow behaviour and decide whether to add -fwrapv to the generated
CFLAGS?)

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....





reply via email to

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