public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/34230]  New: Expressions of parameters evaluated with too high precision
Date: Sun, 25 Nov 2007 21:44:00 -0000	[thread overview]
Message-ID: <bug-34230-13404@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2007-11-25 21:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-25 21:44 burnus at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-34230-13404@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).