[PATCH] Document arithmetic overflow semantics
Roger Sayle
roger@www.eyesopen.com
Thu Feb 13 18:56:00 GMT 2003
> > I'm prepared to drop this entire argument if you can find me just one
>
> The one I mentioned: (a*2)/2.
That'll do. You're right, GCC does optimize this assuming undefined
overflow. Good to my word, I hereby withdraw my patch. There are
more bugs in this area, than I can hope to address.
Interestingly, Microsoft's Visual C/C++ compilers don't optimize this
example. I wonder how much of their 20% SPECint advantage over mainline
GCC is from their use of two's-complement semantics vs. undefined
overflow. For example, they also optimize "z1 = (x+y)+z; z2 = x+(y+z)"
which GCC currently can't.
What can I say. I tried. I failed.
My apologies for any inconvenience.
Roger
--
More information about the Gcc
mailing list