gcc 2.96 optimization bug on RedHat7.0/alpha
Brad Lucier
lucier@math.purdue.edu
Tue Apr 17 21:35:00 GMT 2001
>
> with -O2 i get the wrong answer
>
> [gat@LX gat]$ gcc -g -O2 a.c -o a
> [gat@LX gat]$ ./a
> FlooR: x = 22.16, i0=1, i1=536871996
>
>
> with -O i get a passable answer
>
> [gat@LX gat]$ gcc -g -O a.c -o a
> [gat@LX gat]$ ./a
> FlooR: x = 22.16, i0=1077291253, i1=-1030792151
In ISO C, the compiler can assume that the address of a real is not
the same as the address of an int, and gcc does so unless you give
the -fno-strict-aliasing flag:
popov-9% gcc -v
Reading specs from /export/u10/egcs-test/lib/gcc-lib/alphaev6-unknown-linux-gnu/3.1/specs
Configured with: ../configure --prefix=/export/u10/egcs-test --enable-checking=no --enable-shared=no
gcc version 3.1 20010415 (experimental)
popov-10% gcc -O2 -o a a.c
popov-11% ./a
FlooR: x = 22.16, i0=1, i1=536871788
popov-12% gcc -O2 -fno-strict-aliasing -o a a.c
popov-13% ./a
FlooR: x = 22.16, i0=1077291253, i1=-1030792151
So it may not be a bug.
Brad
More information about the Gcc-bugs
mailing list