From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23761 invoked by alias); 17 Apr 2004 05:22:50 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23754 invoked by uid 48); 17 Apr 2004 05:22:49 -0000 Date: Sat, 17 Apr 2004 05:29:00 -0000 From: "wxy at kivera dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20040417052246.14989.wxy@kivera.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/14989] New: strange double resolution X-Bugzilla-Reason: CC X-SW-Source: 2004-04/txt/msg01393.txt.bz2 List-Id: 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 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. -- Summary: strange double resolution Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wxy at kivera dot com CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14989