Hello, Le 16/06/2013 19:33, Tobias Burnus a écrit : > * PING * > > Minor change: Jakub suggested to print no exception status with older > gfortran programs. Hence, the library now defaults to 0. (Older programs > do not pass this argument to the library.) - I also updated > gfortran.texi for that change. > > Tobias > > > On June 12, 2013 17:50, Tobias Burnus wrote: >> Updated version: >> * Uros suggestions are incorporated >> * Changed from -f(no-)underflow-warning to >> -ffpe-summary=[none,all,underflow,...] >> >> Tobias Burnus wrote: >>> The attached patch causes gfortran-compiled programs to print >>> warnings like >> Note: The following floating-point exception are signalling: >> IEEE_DIVIDE_BY_ZERO >>> when STOP / ERROR STOP is invoked. That's required by Fortran 2008 >>> (8.4 STOP and ERROR STOP statements): >>> >>> "If any exception (14) is signaling on that image, the processor >>> shall issue a warning indicating which exceptions are signaling; this >>> warning shall be on the unit identified by the named constant ERROR >>> UNIT (13.8.2.8)." >> >>> One surely could extend it to allow to completely disable the warning >>> - or to make it more fine grained like "none", "all" plus all single >>> flags (including underflow, denormal and inexact, where by default >>> one leaves out inexact). >> >> Thinking about it, I think that's the better solution: It makes >> (optionally) inexact available and also allows to fully disable the >> feature. I am sure that there are users who would like to have that >> choice. Hence, I update the argument handling and libgfortran's stop.c. >> >> Additions from the J3 list: >> * IBM's "XLF compiler has an option to report fp exceptions including >> underflow and inexact. It is default OFF." >> (which matches ifort) >> >>> Build and regtested on x86-64-gnu-linux. >>> OK for the trunk? >> >> Tobias >> >> PS: I filled PR 57598 to track the warning handling for coarrays. >
Two nits below: > @@ -515,17 +525,37 @@ gfc_handle_fpe_trap_option (const char *arg) > pos++; > > result = 0; > - for (n = 0; exception[n] != NULL; n++) > + if (!trap && strncmp ("none", arg, pos) == 0) > + { > + gfc_option.fpe_summary = 0; > + arg += pos; > + pos = 0; > + continue; > + } > + else if (!trap && strncmp ("all", arg, pos) == 0) > { > + gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL > + | GFC_FPE_ZERO | GFC_FPE_OVERFLOW > + | GFC_FPE_UNDERFLOW | GFC_FPE_INEXACT; > + arg += pos; > + pos = 0; > + continue; > + } > + else > + for (n = 0; exception[n] != NULL; n++) > + { > if (exception[n] && strncmp (exception[n], arg, pos) == 0) > { > - gfc_option.fpe |= opt_exception[n]; > + if (trap) > + gfc_option.fpe |= opt_exception[n]; > + else > + gfc_option.fpe_summary |= opt_exception[n]; > arg += pos; > pos = 0; > result = 1; > break; > } > - } > + } > if (!result) > gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg); -ffpe-trap and -ffpe-summary should better be distinguished here. > } > diff --git a/libgfortran/runtime/stop.c b/libgfortran/runtime/stop.c > index 4805412..2d4fb62 100644 > --- a/libgfortran/runtime/stop.c > +++ b/libgfortran/runtime/stop.c > @@ -32,6 +32,55 @@ see the files COPYING3 and COPYING.RUNTIME respectively. > If not, see > #endif > > > +/* Fortran 2008 demands: If any exception (14) is signaling on that image, > the > + processor shall issue a warning indicating which exceptions are signaling; > + this warning shall be on the unit identified by the named constant > + ERROR_UNIT (13.8.2.8). In line with other compilers, we do not report > + inexact - and we optionally ignore underflow, cf. thread starting at > + http://mailman.j3-fortran.org/pipermail/j3/2013-June/006452.html. */ > + > +static void > +report_exception (void) > +{ > + int set_excepts; > + > + if (!compile_options.fpe_summary) > + return; > + > + set_excepts = get_fpu_except_flags (); > + if ((set_excepts & compile_options.fpe_summary) == 0) > + return; > + > + estr_write ("Note: The following floating-point exceptions are > signalling:"); > + > + if ((compile_options.fpe_summary & GFC_FPE_INVALID) > + && (set_excepts & GFC_FPE_INVALID)) > + estr_write (" IEEE INVALID FLAG"); Two underscores missing. OK once fixed. Thanks Mikael