[Bug fortran/49010] Result of MOD and MODULO intrinsic has wrong sign
sgk at troutmask dot apl.washington.edu
gcc-bugzilla@gcc.gnu.org
Mon May 16 21:29:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49010
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2011-05-16 21:17:44 UTC ---
There is an additional problem with MOD(A,P) and MODULO(A,P).
In F95, one finds "P = 0, the result is processor dependent."
In F2003 and F2008, one finds "P shall not be zero."
Consider the code,
program foo
real, parameter :: b = 0.
real a, p, m1, m2
a = 2.
p = 0.
m1 = mod(a, p)
m2 = mod(a, b)
print *, m1, m2
end program foo
with the __builtin_fmod function we get
troutmask:sgk[215] gfc4x -o z t.f90 && ./z
NaN NaN
(ie., there is no error or warning that P=0).
If we simply eliminate the __builtin_fmod function,
we get
troutmask:sgk[212] gfc4x -o z t.f90 && ./z
2.00000000 2.00000000
which is worse than the NaN. :(
__
Steve
More information about the Gcc-bugs
mailing list