diff options
author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-20 12:55:45 +0000 |
---|---|---|
committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-20 12:55:45 +0000 |
commit | 98b28ab670569a961b4f56a5d4bca75fea37cadc (patch) | |
tree | 7735a57324efcc39f0b3ab6c3034917ad7641e3b /gcc | |
parent | c9819bb0b71ef1482e77c91e7959500fcf261de0 (diff) | |
download | gcc-98b28ab670569a961b4f56a5d4bca75fea37cadc.tar.gz |
Clarify FP exception documentation and messages
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173944 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/gfortran.texi | 11 | ||||
-rw-r--r-- | gcc/fortran/invoke.texi | 40 | ||||
-rw-r--r-- | gcc/fortran/libgfortran.h | 2 | ||||
-rw-r--r-- | gcc/fortran/options.c | 6 |
5 files changed, 44 insertions, 25 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a6fffdfd4d0..5677c4c48fa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,4 +1,12 @@ -2011-06-19 Tobias Burnus <burnus@net-b.de> +2011-05-20 Janne Blomqvist <jb@gcc.gnu.org> + + * gfortran.texi (set_fpe): Update documentation. + * invoke.texi (-ffpe-trap): Likewise. + * libgfortran.h (GFC_FPE_PRECISION): Rename to GFC_FPE_INEXACT. + * options.c (gfc_handle_fpe_trap_option): Handle inexact and make + precision an alias for it. + +2011-05-19 Tobias Burnus <burnus@net-b.de> PR fortran/18918 * trans-types.c (gfc_get_element_type): Handle scalar coarrays. diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 995d9d8eab8..4db506c5391 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -2718,16 +2718,15 @@ int main (int argc, char *argv[]) @node _gfortran_set_fpe -@subsection @code{_gfortran_set_fpe} --- Set when a Floating Point Exception should be raised +@subsection @code{_gfortran_set_fpe} --- Enable floating point exception traps @fnindex _gfortran_set_fpe @cindex libgfortran initialization, set_fpe @table @asis @item @emph{Description}: -@code{_gfortran_set_fpe} sets the IEEE exceptions for which a -Floating Point Exception (FPE) should be raised. On most systems, -this will result in a SIGFPE signal being sent and the program -being interrupted. +@code{_gfortran_set_fpe} enables floating point exception traps for +the specified exceptions. On most systems, this will result in a +SIGFPE signal being sent and the program being aborted. @item @emph{Syntax}: @code{void _gfortran_set_fpe (int val)} @@ -2738,7 +2737,7 @@ being interrupted. (bitwise or-ed) zero (0, default) no trapping, @code{GFC_FPE_INVALID} (1), @code{GFC_FPE_DENORMAL} (2), @code{GFC_FPE_ZERO} (4), @code{GFC_FPE_OVERFLOW} (8), -@code{GFC_FPE_UNDERFLOW} (16), and @code{GFC_FPE_PRECISION} (32). +@code{GFC_FPE_UNDERFLOW} (16), and @code{GFC_FPE_INEXACT} (32). @end multitable @item @emph{Example}: diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index ab45072efad..41fee670a6c 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -919,21 +919,31 @@ GNU Fortran compiler itself. This option is deprecated; use @item -ffpe-trap=@var{list} @opindex @code{ffpe-trap=}@var{list} -Specify a list of IEEE exceptions when a Floating Point Exception -(FPE) should be raised. On most systems, this will result in a SIGFPE -signal being sent and the program being interrupted, producing a core -file useful for debugging. @var{list} is a (possibly empty) comma-separated -list of the following IEEE exceptions: @samp{invalid} (invalid floating -point operation, such as @code{SQRT(-1.0)}), @samp{zero} (division by -zero), @samp{overflow} (overflow in a floating point operation), -@samp{underflow} (underflow in a floating point operation), -@samp{precision} (loss of precision during operation) and @samp{denormal} -(operation produced a denormal value). - -Some of the routines in the Fortran runtime library, like -@samp{CPU_TIME}, are likely to trigger floating point exceptions when -@code{ffpe-trap=precision} is used. For this reason, the use of -@code{ffpe-trap=precision} is not recommended. +Specify a list of floating point exception traps to enable. On most +systems, if a floating point exception occurs and the trap for that +exception is enabled, a SIGFPE signal will be sent and the program +being aborted, producing a core file useful for debugging. @var{list} +is a (possibly empty) comma-separated list of the following +exceptions: @samp{invalid} (invalid floating point operation, such as +@code{SQRT(-1.0)}), @samp{zero} (division by zero), @samp{overflow} +(overflow in a floating point operation), @samp{underflow} (underflow +in a floating point operation), @samp{inexact} (loss of precision +during operation), and @samp{denormal} (operation performed on a +denormal value). The first five exceptions correspond to the five +IEEE 754 exceptions, whereas the last one (@samp{denormal}) is not +part of the IEEE 754 standard but is available on some common +architectures such as x86. + +The first three exceptions (@samp{invalid}, @samp{zero}, and +@samp{overflow}) often indicate serious errors, and unless the program +has provisions for dealing with these exceptions, enabling traps for +these three exceptions is probably a good idea. + +Many, if not most, floating point operations incur loss of precision +due to rounding, and hence the @code{ffpe-trap=inexact} is likely to +be uninteresting in practice. + +By default no exception traps are enabled. @item -fno-backtrace @opindex @code{fno-backtrace} diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h index 035a32a7507..b2137bbf80f 100644 --- a/gcc/fortran/libgfortran.h +++ b/gcc/fortran/libgfortran.h @@ -42,7 +42,7 @@ along with GCC; see the file COPYING3. If not see #define GFC_FPE_ZERO (1<<2) #define GFC_FPE_OVERFLOW (1<<3) #define GFC_FPE_UNDERFLOW (1<<4) -#define GFC_FPE_PRECISION (1<<5) +#define GFC_FPE_INEXACT (1<<5) /* Bitmasks for the various runtime checks that can be enabled. */ diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 920b95f33fe..4c59bd59eeb 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -492,12 +492,14 @@ static void gfc_handle_fpe_trap_option (const char *arg) { int result, pos = 0, n; + /* precision is a backwards compatibility alias for inexact. */ static const char * const exception[] = { "invalid", "denormal", "zero", "overflow", "underflow", - "precision", NULL }; + "inexact", "precision", NULL }; static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL, GFC_FPE_ZERO, GFC_FPE_OVERFLOW, - GFC_FPE_UNDERFLOW, GFC_FPE_PRECISION, + GFC_FPE_UNDERFLOW, GFC_FPE_INEXACT, + GFC_FPE_INEXACT, 0 }; while (*arg) |