On Thu, Nov 27, 2025 at 10:01 AM Xi Ruoyao <[email protected]> wrote:
>
> Current wording may cause people to mistakely believe "hey I use
> -ftrapping-math so GCC should behave as-if it supported FENV_ACCESS and
> I enabled it" and add more duplicates of PR 34678.  Let's make it clear
> such an expectation isn't working.

There is also dead code elimination.  And moving FP operations
across fetestexcept and friends.  It's not very well specified what
-ftrapping-math should do here [when optimizing].  Currently it's
main purpose is to ensure no new spurios traps happen when
an alternate exception handling method (raise a signal) is in effect.

I think a fairer edit would be to remove mentions of FENV_ACCESS from
the option description and instead somewhere else document that
we do not implement FENV_ACCESS.

Richard.

>
> gcc/
>
>         PR middle-end/34678
>         * doc/invoke.texi (-fno-trapping-math): Note that the
>         -ftrapping-math effect is weaker than enabling FENV_ACCESS.
> ---
>  gcc/doc/invoke.texi | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index b1e6d703702..1f0988cfc6d 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -16129,7 +16129,13 @@ The default is @option{-ftrapping-math}.
>  Future versions of GCC may provide finer control of this setting
>  using C99's @code{FENV_ACCESS} pragma.  This command-line option
>  will be used along with @option{-frounding-math} to specify the
> -default state for @code{FENV_ACCESS}.
> +default state for @code{FENV_ACCESS}.  But note that as at now GCC
> +does not support the @code{FENV_ACCESS} pragma yet, and the effect of
> +@option{-ftrapping-math} is less strict than enabling the
> +@code{FENV_ACCESS} pragma (on a compiler supporting it): GCC can still
> +omit a floating-point exception if the result of the floating-point
> +calculation can be determined at the compile time, even with
> +@option{-ftrapping-math}.
>
>  @opindex frounding-math
>  @item -frounding-math
> --
> 2.52.0
>

Reply via email to