[Bug c/54192] -fno-trapping-math by default?

gabravier at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Sep 21 00:51:54 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54192

Gabriel Ravier <gabravier at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gabravier at gmail dot com

--- Comment #5 from Gabriel Ravier <gabravier at gmail dot com> ---
Also of note should be the fact that Clang's current default is
`-fno-trapping-math`.

I'm myself kind of curious about how exactly `-ftrapping-math` is interpreted.
It certainly doesn't seem to remove every single kind of non-trapping
math-based optimization: GCC will remove such statements as `(void)1/x;` even
with `-ftrapping-math`, even though that could fault with `x == 0`, and will
optimize things like `float x = 3412897421;` to not do a conversion even though
that conversion could raise an exception (as 3412897421 cannot be exactly
represented as a float), whereas Clang won't do that kind of optimization and
will keep those operations as-is.


More information about the Gcc-bugs mailing list