NaN are special in so far that
if(nan /= nan)
evaluates as TRUE (see IEEE 754 and IEEE 754r). This is the case if the
variable is not a parameter, however, for parameters the wrong thing is
returned (compile with -fno-range-check):
real,parameter :: r = 0.0/0.0
! real :: r = 0.0/0.0
! if (0.0/0.0 == 0.0/0.0) then ! same result as a parameter.
if (r == r) then
print *, "not NaN" ! printed for parameters with NaN value
else
print *, "NaN" ! printed for variables with NaN value
end if
end
For consistency, for PARMETER the result should be the same as for variables;
this is also what g95, ifort, openf95 and sunf95 do.
--
Summary: if(nan == nan) wrongly returns TRUE, when nan is a
parameter
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34333