This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: check if is NaN
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: check if is NaN
- From: Thomas dot Koenig at cologne dot de
- Date: Wed, 9 Aug 2000 16:49:43 +0200 (CEST)
- Newsgroups: comp.lang.fortran
- References: <8mr7bo$bf1$1@nnrp1.deja.com>
(Cc: to gcc-bugs@gcc.gnu.org)
In article <8mr7bo$bf1$1@nnrp1.deja.com>, <ezio_riva@my-deja.com> 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...
What I would really like, I suppose, would be an ISNAN intrinsic
function.
BTW,
isnand = a.ge. 0. .or. a .ne. 0.
works, but a very clever optimizer could also optimize this away...