http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53332
Bug #: 53332 Summary: #pragma STDC FLOAT_CONST_DECIMAL64 ON done wrong Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: tyde...@tybor.com The following code shows problems with floating-point constants and implied decimal suffix. x10 ends up as a NaN and x2 ends up as zero (both wrong). #define __STDC_WANT_DEC_FP__ /* Tell implementation that we want Decimal FP */ #pragma STDC FLOAT_CONST_DECIMAL64 ON #include <stdio.h> int main(void){ double d2 = (_Decimal64)((28.DD/3.DD-9.DD) - (31.DD/3.DD-10.DD)); /* decimal FP */ _Decimal64 d10 = (_Decimal64)((28.DD/3.DD-9.DD) - (31.DD/3.DD-10.DD)); double b2 = (_Decimal64)((28.D /3.D -9.D ) - (31.D /3.D -10.D )); /* binary FP */ _Decimal64 b10 = (_Decimal64)((28.D /3.D -9.D ) - (31.D /3.D -10.D )); double x2 = (_Decimal64)((28./3.-9.) - (31./3.-10.)); /* should be decimal FP */ _Decimal64 x10 = (_Decimal64)((28./3.-9.) - (31./3.-10.)); if( d2 != x2 ){ (void) printf(" d2 is %g, b2 is %g, x2 is %g\n", (double)d2, (double)b2, (double)x2 ); } if( d10 != x10 ){ (void) printf("d10 is %g, b10 is %g, x10 is %g\n", (double)d10, (double)b10, (double)x10 ); } return 0; } This is on Intel CPUs in both 32-bit and 64-bit mode. This is with Fedora Core Linux 14 thru 17. This is with gcc 4.5.1 thru 4.7.0