wbailey@flame.oracle.com (Bill Bailey) (02/01/90)
Dear rms:
I believe the code below demonstrates a generic bug with gcc 1.36.
It is at least a problem on sparc where I built gcc 1.36.
It prints "false, true" when it should print "false, false." Note
the second if clause is the problematic one, I include the first
simply to illustrate the inconsistency.
I spent some time in dbx working on this. The problem almost certainly
has to do with the routine shorten_compare() but I can't quite pin
it down. Please let me know if there is a simple fix.
Thank you.
wbailey@oracle.com
main()
{
char i = 1;
int j = 1;
if ( i < -128 )
printf("true, ");
else
printf("false, ");
if ( j < -2147483648 )
printf("true\n");
else
printf("false\n");
}
pcg@aber-cs.UUCP (Piercarlo Grandi) (02/05/90)
In article <9002010531.AA02596@flame.oracle.com> wbailey@flame.oracle.com (Bill Bailey) writes: if ( j < -2147483648 ) ^^^^^^^^^^^ Let's give a hint: is this a constant or an expression? If it is an expression, is its value what you think it to be? What about two's complement signed arithmetic? Enough said... -- Piercarlo "Peter" Grandi | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcvax!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk