This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: check if is NaN


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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]