https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29186
--- Comment #24 from Richard Biener <rguenth at gcc dot gnu.org> --- For the division when GCC doesn't know the divident is not zero I think we actually fixed the bug but yes, in general FP operation reordering wrt FP env access isn't fixed. But GCC needs to consider that feclear/testexcept exit the program and since the division may trap it cannot hoist it before the feclearexcept call. It might move it after the fetestexcept call though (delaying traps is OK). As soon as we start to put more knowledge about feclearexcept into GCC this will break again. Oh - we actually do know this since GCC 8 ... So you're just lucky indeed ...