The standard allows this behavior. "#pragma fenv_access on" can be used to disable the optimization.  (Neither clang nor gcc actually support this pragma because the vast majority of programs don't care...)