When compiling the following the code with gcc 4.1.1 without
optimization, the output is wrong.
gcc -v is
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/home/jb/local
Thread model: posix
gcc version 4.1.1
<=====code=====>
#include<stdio.h>
int main()
{
int b[2] = {3, 5};
b[0] ^= b[1] ^= b[0] ^= b[1];
printf("b[0] = %d, b[1] = %d\n", b[0], b[1]);
return 0;
}
<=====/code====>
with -O0, the output is
b[0] = 0, b[1] = 3
whereas with -O1 (or -O2 or -O3), it's
b[0] = 5, b[1] = 3
i was able to reproduce this on x86, HP/UX and AIX
Please, tell me if you need any more info.
-jb
--
Endless Loop: n.,see Loop, Endless.
Loop Endless: n.,see Endless Loop.
-Anonymous