inverted logic in arith.c:gfc_range_check()?

Steve Kargl sgk@troutmask.apl.washington.edu
Sun May 16 19:23:00 GMT 2004


On Sun, May 16, 2004 at 07:02:49PM +0100, Paul Brook wrote:
> On Sunday 16 May 2004 18:52, Steve Kargl wrote:
> >
> > seems contrary to the value of (1e50, 1.).  Should "!=" actually
> > be "=="?  That is, if the real is ok, then check the imaginary part.
> 
> Well spotted. Fixed as follows.
> 
> Paul
> 

I'm looking at PR 14059, which is

In file b.f90:5

   x = sqrt(9.125)**2 - 9.125                                  
          1
Error: Arithmetic underflow at (1)

Several functions in arith.c, eg., gfc_arith_plus(), 
contain the following chunk 

  rc = gfc_range_check (result);

  if (rc != ARITH_OK)
    gfc_free_expr (result);
  else
    *resultp = result;

  return rc;

My current thinking is to change this to 

  if (rc == ARITH_UNDERFLOW)
    {
      gfc_warning(some phrase)
      rc == ARITH_OK;
      result->... = 0;
      *resultp = result;
    }
  else if (rc != ARITH_OK)
    gfc_free_expr (result);
  else
    *resultp = result;

  return rc;

Does this seem reasonable?

-- 
Steve



More information about the Gcc-patches mailing list