public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34230]  New: Expressions of parameters evaluated with too high precision
@ 2007-11-25 21:44 burnus at gcc dot gnu dot org
  2007-11-26  0:12 ` [Bug fortran/34230] " kargl at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-11-25 21:44 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-12-02 21:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-25 21:44 [Bug fortran/34230] New: Expressions of parameters evaluated with too high precision burnus at gcc dot gnu dot org
2007-11-26  0:12 ` [Bug fortran/34230] " kargl at gcc dot gnu dot org
2007-11-27 21:57 ` terry at chem dot gu dot se
2007-11-27 22:45 ` kargl at gcc dot gnu dot org
2007-11-27 22:57 ` terry at chem dot gu dot se
2007-11-28  0:06 ` kargl at gcc dot gnu dot org
2007-11-28 18:03 ` fxcoudert at gcc dot gnu dot org
2007-11-28 19:06 ` kargl at gcc dot gnu dot org
2007-11-28 19:24 ` fxcoudert at gcc dot gnu dot org
2007-11-28 19:35 ` burnus at gcc dot gnu dot org
2007-11-28 20:08 ` sgk at troutmask dot apl dot washington dot edu
2007-11-30  4:11 ` jvdelisle at gcc dot gnu dot org
2007-11-30  4:18 ` jvdelisle at gcc dot gnu dot org
2007-12-02 21:02 ` jvdelisle at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).