This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: SIGFPE, Arithmetic exception. "Value optimized out" when using --ffast-math
- From: "N.M. Maclaren" <nmm1 at cam dot ac dot uk>
- To: fortran at gcc dot gnu dot org
- Date: 02 Jul 2011 08:56:21 +0100
- Subject: Re: SIGFPE, Arithmetic exception. "Value optimized out" when using --ffast-math
- References: <4E0B8B0C.4020105@noaa.gov> <20110629210237.GA12888@troutmask.apl.washington.edu> <4E0CCFBB.9010003@noaa.gov> <201106302213.37976.franke.daniel@gmail.com> <4E0DFD94.5050807@noaa.gov> <4E0E1461.7040709@net-b.de>
On Jul 1 2011, Tobias Burnus wrote:
Paul van Delst wrote:
Trying the options one-by-one, it was the -funsafe-math-optimizations
option that caused the program to crash using gfortran 4.4.4. We will
give it a shot on gfortran 4.6.
I guess just the name of that option should raise a red flag, hey? :o)
Maybe - depends how safe your code is ;-)
Precisely. This is one area whether the effect of IEEE 754 has been
extremely harmful, by encouraging mistaken thinking. Back in the days
when we wrote code to run unchanged on a truly bizarre collection of
compilers and floating-point units, every experienced programmer of
portable code knew how to write (fairly) safe code. That skill is now
rare.
Despite common belief, what constitutes an arithmetically exceptional
condition is undefined in all languages except Java and a few others,
and the Fortran standard clearly states that it allows aggressive
optimisations and does not define behaviour on exceptions. That is
also true for C and C++, though it is less clear or well-understood.
Usually, one wants to allow the compiler to do all optimizations, except
those few which lead to relevant changes in the output - unfortunately,
no such -foptimize_as_I_want flag exists. ...
Largely because of the lack of the DWIM instruction :-)
Regards,
Nick Maclaren.