This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran,patch] Add option to raise FPE
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: François-Xavier Coudert <fxcoudert at gmail dot com>
- Cc: gfortran <fortran at gcc dot gnu dot org>, patch <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 25 Aug 2005 11:54:42 +0200
- Subject: Re: [gfortran,patch] Add option to raise FPE
- References: <19c433eb050819161749f6fb8f@mail.gmail.com>
On 8/20/05, François-Xavier Coudert <fxcoudert@gmail.com> wrote:
> Hi all,
>
> Attached patch adds support for an interesting feature present in many
> commercial compilers: raising a floating-point exception (FPE) when a
> IEEE exception is encountered (invalid operation, such as sqrt(-1.0),
> overflow, underflow, division by zero, loss of precision and denormal
> numbers). This is very interesting for debugging, since it enables one to
> know where a numerical computation have gone wrong, when you do not
> expect NaN to creep into your results, for example.
>
> Commercial compilers allow to do this with a compile-time option, which I
> added to gfortran: I called it -ffpe-trap, though -ffpe-raise might be a
> better name (any other ideas welcome). It is to be used in the following
> way:
> gfortran fpe-test.f90 -ffpe-trap=invalid,overflow
> where -ffpe-trap accepts a comma-separated list of IEEE exceptions
> (invalid,overflow,underflow,zero,precision,denormal).
Please try to make this language independend! It's useful at least
for C and C++,
too. You might want to look at HJs patch to disable denormals handling on i386.
Richard.