I would like to compile a program with gfortran and -O3 -ffast-math
enabled, since it gives a nice performance boost. I was rather confused, that gfortran\'s
I was facing the same problem in gfortran-4.7 and started to experiment with some expressions. For my Test Cases this one returned true if x is a NaN:
check = ((x*2d0==x).AND.(
(x<-epsilon(1.d0)).OR.
(x>+epsilon(1.d0))))
I've checked only double precision values and -O2 -ffast-math, -O3 -ffast-math options. Note that this returns .false. if using no optimization flags, thus you would have to combine it with
isnan(x) .OR. check