https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93806
--- Comment #9 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> --- (In reply to Alexander Cherepanov from comment #8) > A similar problem happens with -fno-signed-zeros -fno-trapping-math. Not > sure if a separate PR should be filed... Concerning -fno-signed-zeros, your code has undefined behavior since the sign of zero is significant in "1 / x == 1 / 0.", i.e. changing the sign of 0 changes the result. If you use this option, you are telling GCC that this cannot be the case. Thus IMHO, this is not a bug. I would say that -fno-trapping-math should have no effect because there are no traps by default (for floating point). But since your code has undefined behavior, this is not necessarily surprising.