hamilton@uiucuxc.UUCP (04/20/84)
#N:uiucuxc:18900004:000:255
uiucuxc!hamilton Apr 20 04:06:00 1984
try this on your 68k C compiler.
wayne ({decvax,ucbvax}!pur-ee!uiucdcs!uiucuxc!)hamilton
main()
{
int n = 1;
double x = 2., y, z[2];
y = x + x;
z[n] = x + x;
if (y == z[n])
printf ("equal\n");
else
printf ("NOT equal?\n");
}
grunwald@uiuccsb.UUCP (04/21/84)
#R:uiucuxc:18900004:uiuccsb:13700001:000:534 uiuccsb!grunwald Apr 21 11:46:00 1984 Here's the offending code which is generated: movl d0,a6@(-20) movl d1,a6@(-16) << first store from x + x movl a6@(-8),sp@- movl a6@(-12),sp@- movl a6@(-8),sp@- movl a6@(-12),sp@- jsr fadd << 2nd x + x computation addl #16,sp lea a6@(-36),a0 movl a6@(-4),d1 asll #3,d1 << compute address offset into z, kill d1 addl d1,a0 movl d0,a0@ << second store into z[n], with corrupted d1 So I guess the compiler blindly assumes that it's o.k. to use d1 for array offset calculations, even when it contains a value. How sad.
rpw3@fortune.UUCP (04/24/84)
#R:uiucuxc:18900004:fortune:6600012:000:563 fortune!rpw3 Apr 23 18:41:00 1984 +-------------------- | try this on your 68k C compiler. | wayne ({decvax,ucbvax}!pur-ee!uiucdcs!uiucuxc!)hamilton | main() | { int n = 1; | double x = 2., y, z[2]; | | y = x + x; | z[n] = x + x; | | if (y == z[n]) | printf ("equal\n"); | else | printf ("NOT equal?\n"); | } +-------------------- Prints "equal" on our machine. Doesn't it on everyone's? ;-} Rob Warnock UUCP: {ihnp4,ucbvax!amd70,hpda,harpo,sri-unix,allegra}!fortune!rpw3 DDD: (415)595-8444 USPS: Fortune Systems Corp, 101 Twin Dolphin Drive, Redwood City, CA 94065