A combiner type optimization is causing a failure

Pranav Bhandarkar pranav.bhandarkar@gmail.com
Thu Feb 22 13:56:00 GMT 2007

Hello all,
I added a small optimization which does the following . It converts
a = a + 1
if ( a > 0 )

if ( a > -1)

a is a signed int.
However this is causing 920612-1.c to fail, which is reproduced below
for convenience.

f(j)int j;{return++j>0;}
main(){ if(f((~0U)>>1)) abort(); exit(0); }

The problem is that this testcase passes the number 2147483647 (int is
4 bytes for my architecture) to which if 1 is added an overflow will
occur. Since I remove the increment operation in 'f' through the
optimization 2147483647 never gets incremented and 'f' always returns
1 and the testcase fails.

My question is that, IMO the test is checking overflow behaviour. Is
it right to have such a test ?

More information about the Gcc mailing list