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 Sun, May 16, 2004 at 06:10:17PM -0700, Steve Kargl wrote:
> On Mon, May 17, 2004 at 12:18:27AM +0100, Paul Brook wrote:
> >
> > 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)
>
I forgot one other complication. I tried adding the gfc_warning
in gfc_range_check. It looked like
gfc_warning ("%s at %L", gfc_arith_error (rc), e->where);
where rc = UNDERFLOW. Unfortunately, the locus is not set in
e, so e->where caused a segfault.
> > if (rc == ARITH_UNDERFLOW)
> > {
> > rc = ARITH_OK;
> > *resultp = result;
Adding a gfc_warning() here is easy.
--
Steve