[Patch, Fortran] Print floating-point exception status after STOP/ERROR STOP

Jakub Jelinek jakub@redhat.com
Wed Jun 12 15:55:00 GMT 2013


On Wed, Jun 12, 2013 at 03:05:30PM +0200, Tobias Burnus wrote:
> --- a/libgfortran/runtime/stop.c
> +++ b/libgfortran/runtime/stop.c
> @@ -32,6 +32,37 @@ 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 = get_fpu_except_flags ();
> +  if (!set_excepts)
> +    return;

I think if you want to mask some exceptions based on
compile_options (and yes, I think it is highly desirable to have
some compile option to disable any printout on STOP with no arguments),
then I think you want to mask them before testing if (!set_excepts),
otherwise if say undeflow is the only reported exception, you'd print
Note: The following floating-point status flag is signalling:
(and no exceptions).  So
if (!compile_options.underflow_warning)
  set_excepts &= ~GFC_FPE_UNDERFLOW;
if (!set_excepts)
  return;

would be IMHO better.

	Jakub



More information about the Gcc-patches mailing list