This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Possible bug in optimization
- From: Chris Croswhite <ccroswhite at get2chip dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Feb 2003 18:58:58 -0800
- Subject: Possible bug in optimization
Here is a simple prog that I think might illustrate a bug in gcc-3.2.1/2
optimization:
#include <stdio.h>
int main(int argc, char **argv)
{
long long val = 0x4000000000000001;
(((int*) &val)[1]) &= 0x0;
printf("%lld\n", val);
return 1;
}
This bit wise operation shows two different results when run with/out
optimization as follows:
gcc -O0 -static -save-temps toto2.c -o toto2-O0
gcc -O2 -static -save-temps toto2.c -o toto2-O2
gcc -O1 -static -save-temps toto2.c -o toto2-O1
gcc -g -static -save-temps toto2.c -o toto2-g
[~]$ ./toto2-O0
1
[~]$ ./toto2-O1
1
[~]$ ./toto2-O2
4611686018427387905
[~]$ ./toto2-g
1
Using gcc 3.2.2 and gcc3.2.1 (release) on AMD Athlon and Xeon (i686).
Built using: --enable-languages=c,c++ --prefix=/usr/local/gcc322
If someone tell me what I have done wrong, I would really appreciate it.
TIA,
Chris
--
Chris Croswhite <ccroswhite@get2chip.com>
Get2Chip, Inc.