This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
here is gcc -v: Reading specs from /exp/opt/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs Configured with: ../gcc-3.3.3/configure --prefix=/exp/opt/gcc3 Thread model: posix gcc version 3.3.3 here is the source code big.cc: #include <cstdio> int main() { #ifdef SINGLE long long a = 8000000000000000000ll, b = a + 1; #else long long p = 2000000ll, a = p * p * p, b = a + 1; #endif double x = a, y = b; #ifdef PRINT printf("%lld %lld\n", a, b); #endif printf("%s %s\n", a == b ? "yes" : "no", x == y ? "yes" : "no"); } note: a and b are 8 byte long long differ by 1 with magnitude of 63 bits. x and y are 8 byte double with only 53 bits resolution. When x and y are assigned the value of a and b, they should have same value, and the last line should print no yes. If I compile with (gcc -Wall -O big.cc), the program prints (unexpected) no no. If I compile with (gcc -Wall big.cc) or (gcc -Wall -O -DSINGLE big.cc) or (gcc -Wall -O -DPRINT big.cc), I get the expected "no yes". I am puzzled by the fact that -DSINGLE or -DPRINT made a difference.
on solaris, it works as expected, everything prints no yes. here is gcc -v: Reading specs from /net/mars/exp/opt/gcc/lib/gcc-lib/sparc-sun-solaris2.8/3.3.3/specs Configured with: ../gcc-3.3.3/configure --prefix=/net/mars/exp/opt/gcc Thread model: posix gcc version 3.3.3
This is a dup of bug 323, read that bug and see why it is considered a non-bug. *** This bug has been marked as a duplicate of 323 *** *** This bug has been marked as a duplicate of 323 ***