This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: check if is NaN
- To: Thomas dot Koenig at cologne dot de
- Subject: Re: check if is NaN
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Wed, 09 Aug 2000 22:02:46 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- Newsgroups: comp.lang.fortran
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <8mr7bo$bf1$1@nnrp1.deja.com> <20000809144943.DC41297B50@mvmap66.ciw.uni-karlsruhe.de>
Thomas.Koenig@cologne.de wrote:
> >a) I 'm using g77 but I need to use the option -ffast-math.
>
> I was quite surprised that
>
> external isnand
> logical isnand
> double precision a
> a = acos(1.2)
> print *,a,isnand(a)
> end
> logical function isnand(a)
> double precision a
> isnand = a .ne. a
> end
>
> produced
>
> NAN F
>
> with GNU Fortran 0.5.25 19991030 (prerelease) on Linux i386 and
> compilation with -O4 -ffast-math. Inspection of the generated assembly
> code showed
>
> .globl isnand_
> .type isnand_,@function
> isnand_:
> pushl %ebp
> movl %esp,%ebp
> xorl %eax,%eax
> leave
> ret
>
> which shows that the test was optimized away.
>
> I'm not sure wether to classify this as a bug or not. The documentation
> warns that -ffast-math makes programs non IEEE-conforming, but still...
Exactly - moreover, I have warned about this behaviour in the past on
comp.lang.fortran.
I'm sorry - the whole purpose of -ffast-math is to cut corners,
especially where following the IEEE standard zealously would incur
significant overhead.
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://g95.sourceforge.net/ (under construction)