[Top][All Lists]

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

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

From: Richard Kenner
Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Sat, 30 Dec 2006 08:01:37 EST

> Paul Eggert wrote:
> > 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.)
> That's handwaving, not evidence.  Sorry, I'm unconvinced.

I am too.  Although I'm willing to grant the possibility of such bugs in GCC,
I'd actually be very surprised if there were ANYPLACE where GCC has code
that's otherwise correct but which would malfunction if signed overflow
weren't required to wrap.  The code you showed is a place where it MIGHT,
but, as I said, it has another bug and will ALSO do the wrong thing for
certain ranges of sizes that will NOT cause that code to overflow (indeed,
for those ranges of sizes the code won't even in question won't even be

There are certainly cases where overflow does occur in doing tree arithmetic.
But each case is either detected by setting an overflow bit in the tree or
is in a context where an undefined result is appropriate because that
matches the semantics of the language being compiled.  It is always
possible that some code that's supposed to test the overflow bit doesn't
do it (or that it doesn't get set where it should) and in such a case,
it's possible that changing the overflow behavior would change the
compiled code, but that's also a case where the mishandling of the overflow
bit would itself be a bug completely undependently of the overflow issue.

reply via email to

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