Using gcc 4.3.2-7 on Intel Pentium 4 running Linux Fedora Core 10 and -std=gnu99
/* DFP TR 24732 == WG14 / N1176, N1312 */ #define __STDC_WANT_DEC_FP__ /* Tell implementation that we want Decimal FP */ #pragma STDC FENV_ACCESS ON /* will be testing FP exception flags */ #include <stdio.h> /* printf() */ #include <fenv.h> /* fetestexcept(), FE_* */ #include <float.h> /* DEC*_MIN, DEC*_MAX */ int main(void){ _Decimal64 d10; int before; int after; before = feclearexcept( FE_ALL_EXCEPT ); d10 = 1.0DD; d10 /= 3.0DD; after = fetestexcept( FE_ALL_EXCEPT ); if( FE_INEXACT & after ){ printf("Inexact raised as expected\n"); }else{ printf("Inexact wrong; after=%i\n", after); } before = feclearexcept( FE_ALL_EXCEPT ); d10 = DEC64_MIN; d10 *= d10; after = fetestexcept( FE_ALL_EXCEPT ); if( FE_UNDERFLOW & after ){ printf("Underflow raised as expected\n"); }else{ printf("Underflow wrong; after=%i\n", after); } before = feclearexcept( FE_ALL_EXCEPT ); d10 = DEC64_MAX; d10 *= d10; after = fetestexcept( FE_ALL_EXCEPT ); if( FE_OVERFLOW & after ){ printf("Overflow raised as expected\n"); }else{ printf("Overflow wrong; after=%i\n", after); } before = feclearexcept( FE_ALL_EXCEPT ); d10 = DEC64_MIN; d10 /= (d10-d10); after = fetestexcept( FE_ALL_EXCEPT ); if( FE_DIVBYZERO & after ){ printf("Divbyzero raised as expected\n"); }else{ printf("Divbyzero wrong; after=%i\n", after); } before = feclearexcept( FE_ALL_EXCEPT ); d10 = 0.0e-15DD; d10 /= d10; after = fetestexcept( FE_ALL_EXCEPT ); if( FE_INVALID & after ){ printf("Invalid raised as expected\n"); }else{ printf("Invalid wrong; after=%i\n", after); } printf("%2i = FE_INEXACT\n", FE_INEXACT); printf("%2i = FE_UNDERFLOW\n", FE_UNDERFLOW); printf("%2i = FE_OVERFLOW\n", FE_OVERFLOW); printf("%2i = FE_DIVBYZERO\n", FE_DIVBYZERO); printf("%2i = FE_INVALID\n", FE_INVALID); return 0; } gets: Inexact wrong; after=0 Underflow wrong; after=0 Overflow wrong; after=32 Divbyzero wrong; after=0 Invalid wrong; after=0 32 = FE_INEXACT 16 = FE_UNDERFLOW 8 = FE_OVERFLOW 4 = FE_DIVBYZERO 1 = FE_INVALID -- Summary: Decimal floating-point exception flags done wrong Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tydeman at tybor dot com GCC host triplet: 4.3.2 GCC target triplet: 4.3.2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39036