n62@nikhefh.hep.nl (Klamer Schutte) (05/30/89)
I found a bug in the minix-st compiler. The code it run was:
#define MAXUNS 0x7fff
main()
{
printf("Result : %d\n", test2( (long) 1));
}
test2(l)
long l;
{
return l < MININT ? 1 : 0;
}
The script used to compile this was:
cc -DMININT=-0x8000 -o a.out test.c
cc -DMININT=-0x8000L -o b.out test.c
This resulted in execution in the output:
Result: 0 for b.out, which is correct
and
Result: 1 for a.out, which is wrong.
The difference in output from the compiler:
*** test.s.a Thu May 30 11:53:31 1989
--- test.s.b Thu May 30 11:54:05 1989
***************
*** 15,23 ****
.extern _test2
_test2:
link a6,#-0
! move.l 8(a6), a1
! cmp.l #-32768,a1
! bcc I2_3
move.w #1,-(sp)
bra I2_1
I2_3:
--- 15,22 ----
.extern _test2
_test2:
link a6,#-0
! cmp.l #-32768,8(a6)
! bge I2_3
move.w #1,-(sp)
bra I2_1
I2_3:
Clearly the bcc is wrong; also the copy to a1 is suspect.
To prevent the bug in your programs i think the best way is to explicitly
make all hexadecimal long constants long;
This cures the bug.
Klamer.
PS How many more bugs to go with MINIX-ST's compiler?
--
________________________________________________________________________________
Klamer Schutte mcvax!nikhefh!n62 n62@nikhefh.hep.nl