arndt@zyx.ZYX.SE (Arndt Jonasson) (02/07/91)
The version of SunOS is 4.1. -------------------- start of script -------------------- % cat mc.c #include <stdio.h> main() { int i; for (i=0; i<8; i++) test(i<<29); } test(j) int j; { printf("%d\n", j); } % cc -o mc mc.c % mc 0 536870912 1073741824 1610612736 -2147483648 -1610612736 -1073741824 -536870912 % cc -O -o mc mc.c % mc 0 % uname -srm SunOS 4.1 sun4c % -------------------- end of script -------------------- What seems to happen is that the optimizer sees a chance to avoid shifting 'i' all the time, and therefore keeps 'i' shifted left 29 steps, modifying the index arithmetic accordingly. It's basically a good idea, but it only works if the maximum shifted value of 'i' doesn't overflow, which it does here. -- Arndt Jonasson, ZYX AB, Styrmansgatan 6, 114 54 Stockholm, Sweden email address: arndt@zyx.SE or <backbone>!mcsun!sunic!zyx!arndt