carry@deakin.OZ.AU (Carry Varley) (06/11/90)
Here is another bug in the Manx 5.0a Compiler. This bit me when I tried compiling the AmigaTCP package. The compiler modifies a register variable when no assignment has been made, and then tries to use it as clean. I have posted (snail) to Manx, but would appreciate any info on updates, as their BBS is a bit expensive to access from Australia. /* * Example of bug in Aztec 5.0a Amiga 11JUN90 DAV * The variable is kept in a register, corrupted, but still used. * The macro should not have any side-effects ! */ /* Extract a short from a long */ #define hiword(x) ((unsigned short)((x) >> 16)) #define loword(x) ((unsigned short)(x)) /* Extract a byte from a short */ #define hibyte(x) (((x) >> 8) & 0xff) #define lobyte(x) ((x) & 0xff) long a = 0x01010101; main() { test(a); } test(num) register long num; { long f; /* num is kept as register variable * (d2 with -so, d4 if register keyword) */ printf("num initially = %lx\n",num); f = lobyte(loword(num)); /* This line corrupts num */ printf("num now = %lx\n",num); } David Varley using carry@deakin.AU.OZ until I can compile AmigaTCP for SLIP !!