This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/34230] New: Expressions of parameters evaluated with too high precision
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Nov 2007 21:44:25 -0000
- Subject: [Bug fortran/34230] New: Expressions of parameters evaluated with too high precision
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Found by FX. See
http://gcc.gnu.org/ml/fortran/2007-11/msg00208.html
$ cat a.f90
real, parameter :: y = exp(log(huge(y))+20)
real, parameter :: x = log(y)
print *, x, y
end
$ gfortran a.f90 -fno-range-check && ./a.out
108.72284 +Infinity
The problem is the following: gfortran does not do:
y = INF
x = log(y) = log(INF) = INF
but it does:
y = exp(log(huge())+20) = INF
x = log(exp(log(huge())+20)) = log(huge())+20 = 108.7
Calculating with higher precision to obtain "y" is ok (though one gets
different results compared with the run-time evaluation, but I expect that the
differences are only minor. Having the correct precision from the beginning
would be also ok.)
However, I regard it as bug if for expressions using y not y but a variant with
higher precision.
--
Summary: Expressions of parameters evaluated with too high
precision
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code
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=34230