Following test: --cut here-- #define _GNU_SOURCE #include <fenv.h> #include <signal.h> #include <stdlib.h> static void foo (int sig) { exit (0); } float __attribute__((noinline)) test (float x) { return 2.0f / x; }; int main() { signal (SIGFPE, foo); feclearexcept (FE_ALL_EXCEPT); feenableexcept (FE_INEXACT); test (3.0f); abort (); } --cut here-- aborts when compiled with optimizations, since the call to a procedure with a trapping insn is removed. $ gcc -O2 -fnon-call-exceptions -ftrapping-math -lm sf.c $ ./a.out Aborted $ gcc -lm sf.c $ ./a.out $ [...works OK...] A wild guess is to blame tree optimizers, since in 123t.optimized we already have the call removed: main () { <bb 2>: signal (8, foo); feclearexcept (61); feenableexcept (32); abort (); }
FENV access is not implemented.
I think the test is invalid as you can still remove trapping math if the result is not used; even with FENV access implemented.