Warning! Compiler Bug (DecSt.3100)
Chris Anderson
chris at contex.UUCP
Wed Nov 22 06:42:20 AEST 1989
The following program, when compiled on the DecStation 3100,
produces d=0, when it should be d=1:
unsigned a = 2, d;
int b = 1, c = 1;
d = (c >= (b - a + 1));
What happens is that the whole expression is promoted to unsigned as expected,
but then the comparison is changed to ">" and the +1 operation is
"optimized" out. (Note, this happens even without -O). Voila! Bad code.
Beware of unsigned IFs with +1 in them somewhere...
Chris Anderson (contex!chris at uunet.uu.net)
Xyvision, Inc.
More information about the Comp.unix.ultrix
mailing list