public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110957] New: -ffpe-trap and -ffpe-summary options issues
@ 2023-08-09 9:28 ubizjak at gmail dot com
2023-08-13 20:19 ` [Bug fortran/110957] " anlauf at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ubizjak at gmail dot com @ 2023-08-09 9:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110957
Bug ID: 110957
Summary: -ffpe-trap and -ffpe-summary options issues
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: ubizjak at gmail dot com
Target Milestone: ---
A couple of issues with -ffpe-trap and -ffpe-summary options:
a) Invalid argument report should be switched:
$ gfortran -ffpe-summary=aaa ac.f90
f951: Fatal Error: Argument to ‘-ffpe-trap’ is not valid: aaa
compilation terminated.
$ gfortran -ffpe-trap=aaa ac.f90
f951: Fatal Error: Argument to ‘-ffpe-summary’ is not valid: aaa
compilation terminated.
b) Specifying also -fno-trapping-math should be detected and handled
$ gfortran -ffpe-trap=invalid -fno-trapping-math ac.f90
[no diagnostics]
The issue b) should either report incompatibility between options, or force
-ftrapping-math (probably with a warning). Ideally, -ffpe-* should always set
flag_trapping_math, in case the compiler switches to no trapping math by
default in future.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/110957] -ffpe-trap and -ffpe-summary options issues
2023-08-09 9:28 [Bug fortran/110957] New: -ffpe-trap and -ffpe-summary options issues ubizjak at gmail dot com
@ 2023-08-13 20:19 ` anlauf at gcc dot gnu.org
2023-10-06 20:19 ` anlauf at gcc dot gnu.org
2023-10-13 20:07 ` cvs-commit at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-08-13 20:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110957
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2023-08-13
--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed (a). Obvious fix:
diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc
index 27311961325..2d4be853c66 100644
--- a/gcc/fortran/options.cc
+++ b/gcc/fortran/options.cc
@@ -586,7 +586,7 @@ gfc_handle_fpe_option (const char *arg, bool trap)
break;
}
}
- if (!result && !trap)
+ if (!result && trap)
gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg);
else if (!result)
gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s",
arg);
Regarding (b), the gfortran manual says:
-ffpe-summary=list
list can be either ‘none’, ‘all’ or a comma-separated list ...
-ffpe-trap=list
list is a (possibly empty) comma-separated list ...
Unfortunately, 'none' is not accepted for list here, but might be handy.
Need to check where the options conflict can be diagnosed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/110957] -ffpe-trap and -ffpe-summary options issues
2023-08-09 9:28 [Bug fortran/110957] New: -ffpe-trap and -ffpe-summary options issues ubizjak at gmail dot com
2023-08-13 20:19 ` [Bug fortran/110957] " anlauf at gcc dot gnu.org
@ 2023-10-06 20:19 ` anlauf at gcc dot gnu.org
2023-10-13 20:07 ` cvs-commit at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-06 20:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110957
--- Comment #2 from anlauf at gcc dot gnu.org ---
Created attachment 56071
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56071&action=edit
Patch to fix mixed up parsing of fpe options
The attached patch fixes the mixup and adds the possibility to specify
-ffpe-trap=none to clear previously enabled exceptions on the command line.
Will submit this to the list.
Regarding the treatment of -f(no-)trapping-math, I played around a little
bit, and I am unsure what to do.
In gfortran, the option -ffpe-trap only sets the FPU mask in the main and
does nothing else. Which I think is the major (sole?) purpose.
On the other hand, -f(no-)trapping-math has implications that affect
e.g. reassociation. Adding to gfc_post_options() something like
if (gfc_option.fpe != 0 && !flag_trapping_math)
{
gfc_warning_now (0, "Option %<-ffpe-trap=%> enforces "
"%<-ftrapping-math%> for Fortran");
flag_trapping_math = 1;
}
will generate different warnings for -O3 -ffast-math, -Ofast, and might
create more confusion than help users.
I tend to think that this part should not be implemented (now), unless
we better understand the implications of what a change of the defaults
in gcc means to gfortran.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/110957] -ffpe-trap and -ffpe-summary options issues
2023-08-09 9:28 [Bug fortran/110957] New: -ffpe-trap and -ffpe-summary options issues ubizjak at gmail dot com
2023-08-13 20:19 ` [Bug fortran/110957] " anlauf at gcc dot gnu.org
2023-10-06 20:19 ` anlauf at gcc dot gnu.org
@ 2023-10-13 20:07 ` cvs-commit at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-13 20:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110957
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:458c253ccdae9df439b9a452d04e325101e5756e
commit r14-4631-g458c253ccdae9df439b9a452d04e325101e5756e
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Oct 6 22:21:56 2023 +0200
fortran: fix handling of options -ffpe-trap and -ffpe-summary [PR110957]
gcc/fortran/ChangeLog:
PR fortran/110957
* invoke.texi: Update documentation to reflect '-ffpe-trap=none'.
* options.cc (gfc_handle_fpe_option): Fix mixup up of error
messages
for options -ffpe-trap and -ffpe-summary. Accept '-ffpe-trap=none'
to clear FPU traps previously set on command line.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-13 20:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09 9:28 [Bug fortran/110957] New: -ffpe-trap and -ffpe-summary options issues ubizjak at gmail dot com
2023-08-13 20:19 ` [Bug fortran/110957] " anlauf at gcc dot gnu.org
2023-10-06 20:19 ` anlauf at gcc dot gnu.org
2023-10-13 20:07 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).