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

Tobias Burnus burnus@net-b.de
Wed Jun 12 13:05:00 GMT 2013


David: Can you have a look at libgfortran/config/fpu-aix.h - Thanks!
Uros: Can you have a look at libgfortran/config/fpu-387.h - Thanks!


The attached patch causes gfortran-compiled programs to print warnings like

Note: The following floating-point status flag is 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)."


 From the J3 discussion at 
http://mailman.j3-fortran.org/pipermail/j3/2013-June/006452.html
* sunf77 shows this message - and user complained - even if it didn't 
report inexact exceptions
* Intel: There is an option to dis-/enable this option (-assume 
[no]fpe_summary; default: no warning)
* NAG: Never reports inexact. Only underflow handling has a compiler 
option (as users complained; -no_underflow_warning
* PGI reports all (denorm, underflow, inexact) by default (and seemingly 
no compiler option exists)
* Cray: I couldn't find a compiler option to turn the warning on.

The patch below follows NAG by always printing the warning, but the 
underflow warning can be disabled. (It also always ignores denormalized 
status flags.)

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).

Comments?


Test case:

real, volatile :: r
! Divide by zero:
r = 0
r = 1.0/r
! Underflow:
!r = tiny(r)
!r = r/100.
stop
end


Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: execept-stat.diff
Type: text/x-patch
Size: 18111 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130612/172954ef/attachment.bin>


More information about the Fortran mailing list