Using gcc 4.3.2-7 on Intel Pentium 4 running Fedora Core 10 with -std=gnu99 of /* DFP TR 24732 == WG14 / N1176, N1312 */ #define __STDC_WANT_DEC_FP__ /* Tell implementation that we want Decimal FP */ #include <stdio.h> /* printf() */ int main(void){ double d2 = (double)((28./3.-9.) - (31./3.-10.)); _Decimal64 d10 = (double)((28./3.-9.) - (31./3.-10.)); if( d2 ){ printf("d2 should be zero\n"); } if( d10 ){ printf("d10 should be zero\n"); } return 0; } gets: d10 should be zero This should be independent of Translation Time Data Type (TTDT) which has been dropped from the DFP TR as of WG14 N1312.
My analysis shows that d10=0x2fe0000000000003=+3.e-15 So, d10 is not zero, while d2 is zero.
Created attachment 17214 [details] expanded testcase I expanded the testcase to test both constant folding and runtime calculations for all three decimal float types. The problem occurs with 4.3.3 but not with mainline. I can track down the patch that fixed it if anyone is interested. Test results for trunk and 4.3 for powerpc64-linux and x86-linux (bid and dpd): elm3b187% uname -m ppc64 elm3b187% /opt/gcc-nightly/trunk/bin/gcc -DDBG -O2 -std=gnu99 39034.c && ./a.out elm3b187% /opt/gcc-nightly/4.3/bin/gcc -DDBG -O2 -std=gnu99 39034.c && ./a.out line 29: runtime: d32 should be zero line 42: runtime: d64 should be zero line 56: runtime: d128 should be zero Aborted laptop% uname -m i686 laptop% /home/janis/tools/gcc-trunk-bid/bin/gcc -DDBG -O2 -std=gnu99 39034.c && ./a.out laptop% /home/janis/tools/gcc-trunk-dpd/bin/gcc -DDBG -O2 -std=gnu99 39034.c && ./a.out laptop% /home/janis/tools/gcc-4.3.3-bid/bin/gcc -DDBG -O2 -std=gnu99 39034.c && ./a.out line 29: runtime: d32 should be zero line 42: runtime: d64 should be zero line 56: runtime: d128 should be zero Aborted (core dumped) laptop% /home/janis/tools/gcc-4.3.3-dpd/bin/gcc -DDBG -O2 -std=gnu99 39034.c && ./a.out line 29: runtime: d32 should be zero line 42: runtime: d64 should be zero line 56: runtime: d128 should be zero Aborted (core dumped)
Thanks for expanding the test case, Janis. I think this is worthy of a test case in the regression testsuite, which I will submit now.
Subject: Bug 39034 Author: bje Date: Mon Feb 2 23:03:20 2009 New Revision: 143884 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143884 Log: PR c/39034 * gcc.dg/dfp/pr39034.c: New test. Added: trunk/gcc/testsuite/gcc.dg/dfp/pr39034.c Modified: trunk/gcc/testsuite/ChangeLog
This was fixed in mainline by r141432, a fix for PR middle-end/36578. That bug was a regression from 3.3 to 3.4. I'm testing a backport of that fix to the 4.3 branch.
This was fixed in the GCC 4.3 branch on 2009-02-25.
This bug is still open, though it appears to be fixed. Is there any reason?
Fixed.