http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57029
Bug #: 57029 Summary: GCC doesn't set the inexact flag on inexact compile-time int-to-float conversion Classification: Unclassified Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: vincent-...@vinc17.net GCC doesn't set the inexact flag on inexact compile-time int-to-float conversion: #include <stdio.h> #include <fenv.h> #pragma STDC FENV_ACCESS ON void test1 (void) { volatile float c; c = 0x7fffffbf; printf ("c = %a, inexact = %d\n", c, fetestexcept (FE_INEXACT)); } void test2 (void) { volatile float c; volatile int i = 0x7fffffbf; c = i; printf ("c = %a, inexact = %d\n", c, fetestexcept (FE_INEXACT)); } int main (void) { test1 (); test2 (); return 0; } Under Linux/x86_64: $ gcc -std=c99 -O3 conv-int-flt-inex.c -o conv-int-flt-inex -lm $ ./conv-int-flt-inex c = 0x1.fffffep+30, inexact = 0 c = 0x1.fffffep+30, inexact = 32 Ditto without optimizations. Note: the STDC FENV_ACCESS pragma is currently not supported (PR 34678), but I don't think it is directly related (this is not an instruction ordering problem...). This bug has been found from: http://gcc.gnu.org/ml/gcc-help/2013-04/msg00164.html