This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch,fortran] Fix PR19310 unnecessary error for overflowing results
On Sun, Jun 11, 2006 at 05:24:07PM +0100, Paul Brook wrote:
> >
> > AFAIK, mpfr propagates inf and nan according to IEEE-754, so
> > the front-end should be okay. I have insufficient knowledge
> > of what the middle-end and backend do with these values.
> > I did submit a PR 24581 about problems with C99's complex type
> > and these special values. Joseph Meyer seems to disagree
> > with my analysis of the problem.
>
> Are we sure we have inf or nan at this point? ie. do the MPFR arithmetic
> routines always generate inf when a calculation overflows the range of the
> corresponding fortran type?
mpfr is designed to maintain the requested precision by extending
the range if necessary. This is the reason why we have the kludge
for subnormal numbers, which I tried fixing by requiring verion
2.2.0. You can explicitly set the range (emin, emax), but ISTR that
the docs mentioned this could cause problems.
> If they do then I'm happy. If not I think we should be doing that saturation
> in gfc_check_range. Ending up with "too big" finite values is what I want to
> avoid.
I see. In gfc_check_real_range, we have
if (mpfr_sgn (q) == 0)
retval = ARITH_OK;
else if (mpfr_cmp (q, gfc_real_kinds[i].huge) > 0)
retval = ARITH_OVERFLOW;
else if (mpfr_cmp (q, gfc_real_kinds[i].subnormal) < 0)
retval = ARITH_UNDERFLOW;
else if (mpfr_cmp (q, gfc_real_kinds[i].tiny) < 0)
Jerry would place his disabling of range checking above this
block. However, we probably want to explicit set overflow
values to Inf, so the checking should look like
if (mpfr_sgn (q) == 0)
retval = ARITH_OK;
else if (mpfr_cmp (q, gfc_real_kinds[i].huge) > 0)
{
if (disable-checking)
{
set x to inf with the proper sign
retval = ARITH_OK;
}
else
retval = ARITH_OVERFLOW;
}
else if (mpfr_cmp (q, gfc_real_kinds[i].subnormal) < 0)
retval = ARITH_UNDERFLOW;
else if (mpfr_cmp (q, gfc_real_kinds[i].tiny) < 0)
--
Steve