Bug 14989 - strange double resolution
Summary: strange double resolution
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-17 05:22 UTC by xiaoyi_wu
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xiaoyi_wu 2004-04-17 05:22:46 UTC
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.
Comment 1 xiaoyi_wu 2004-04-17 05:27:31 UTC
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
Comment 2 Andrew Pinski 2004-04-17 05:29:24 UTC
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 ***