This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
bug in 4.1.1?
- From: jimmy <jimmyb at huawei dot com>
- To: gcc at gcc dot gnu dot org
- Cc: fantadox at huawei dot com, maheshsb at huawei dot com
- Date: Sun, 13 Aug 2006 17:28:04 +0530
- Subject: bug in 4.1.1?
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