This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/34230] New: Expressions of parameters evaluated with too high precision


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]