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

kargl at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Nov 27 22:45:00 GMT 2007



------- Comment #3 from kargl at gcc dot gnu dot org  2007-11-27 22:45 -------
(In reply to comment #2)
> (In reply to comment #1)
> > There is no bug here.  You have explicitly disabled
> > range checking.  This means that you no longer have
> > a limitation on range in constant folding.  It may
> > be help to look at -fdump-parse-tree.  YOu don't
> > have an Inf until you actually do the transfer.
> > 
> 
> In that case it's a wrong code bug.

No!

> With -fno-range-check you've told the
> compiler to produce +Infinity rather than an overflow error.

No! No!

It does not say to produce a +Infinity.  It says to produce
whatever value fits into a floating point number with a
p-bit significand and exponential range of [-IMAX, IMAX]
where p depends on the type kind parameter and IMAX is either
INT_MAX or LONG_MAX.  The internal representation of a 
floating point constant is done with MPFR.


> Instead, it takes it upon itself to produce something other
> than what the source says [which is log(y), not log(some
> expression that may or may not be called y)].

No! No! No!

troutmask:kargl[205] cat a.f90
   real, parameter :: y = exp(log(huge(y))+20)
   real, parameter :: x = log(y)
   print *, x, y
   end

troutmask:kargl[206] gfc -fdump-parse-tree -fno-range-check a.f90

        symtree: y  Ambig 0
        symbol y (REAL 4)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
        value: 1.65093201e47

        symtree: x  Ambig 0
        symbol x (REAL 4)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
        value: 1.08722839e2


      WRITE UNIT=6 FMT=-1
        TRANSFER 1.08722839e2
        TRANSFER 1.65093201e47
      DT_END

Do you see +Infinity?

troutmask:kargl[209] cat a.f90
   real, parameter :: x = 1. / 0.
   print *, x
   end
troutmask:kargl[210] gfc -fdump-parse-tree -fno-range-check a.f90

        symtree: x  Ambig 0
        symbol x (REAL 4)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
        value: @Inf@


      WRITE UNIT=6 FMT=-1
        TRANSFER @Inf@
      DT_END

If one doesn't understand what a compiler option does, then it would
be prudent not to use that option.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34230



More information about the Gcc-bugs mailing list