This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Possible fix to PR 14059
On Mon, May 17, 2004 at 12:18:27AM +0100, Paul Brook wrote:
> On Sunday 16 May 2004 21:37, Steve Kargl wrote:
> > Gang,
> >
> > Below is a patch that may be a fix for 14059.
>
> Please supply ChangeLog entries with patches.
This was a request for comments, not the final patch.
> gfc_range_check should be renamed, and the comment updated to
> indicate that it may change the value of the expression.
Do you have a suggestion for a new function name? Would
you prefer a new function, say, gfc_handle_underflow?
>
> > Should gfortran issue a warning for the UNDERFLOW?
>
> If we bother checking for underflow, we may as well allow issuing of a
> warning.
Okay. I'll add appropriate gfc_warnings. Do you have a prefered
option flag, -Wunderflow? Also, I assume we want the warning to
be issued unless the user specifies the compiler flag?
> if (rc == ARITH_UNDERFLOW)
> {
> rc = ARITH_OK;
> *resultp = result;
> }
> else if (rc != ARITH_OK)
gfc_free_expr (result);
You clipped the free().
>
> Would be better written as
>
> if (rc != ARITH_OK && rc != ARITH_UNDERFLOW)
1) I was concerned with correctly freeing memory as above.
2) I tried the (rc != ARITH_OK && rc != ARITH_UNDERFLOW) construct,
but once we set the underflow to zero, we need to reset rc to
ARITH_OK. The "return rc" becomes somewhat uglier.
return ((rc == ARITH_UNDERFLOW) ? ARITH_OK : rc)
> Either way, I think this logic would be better moved into gfc_range_check.
I look into the possibility. We need to deal with freeing memory.
> What about all the other places that use gfc_check_range
> / gfc_check_real_range, should they still issue errors? For example,
> ifort accepts the following without complaint:
>
> real :: r = 1.0e-99
>
> Where TINY(r) == 1.1754943E-38
>
NAG issues a warning for the above
kargl[263] f95 -o n n.f90
Warning: n.f90, line 2: Underflow in single-precision real literal \
constant 1E-99
kargl[264] ./n
0.0000000E+00
I just realized that gfc_range_check also appears in primary.c and
simplify.c. I look at these and make appropriate changes. I'll
also look at the gfc_check_real_range cases.
--
Steve