inverted logic in arith.c:gfc_range_check()?
Paul Brook
paul@codesourcery.com
Sun May 16 18:02:00 GMT 2004
On Sunday 16 May 2004 18:52, Steve Kargl wrote:
> Gang,
>
> In reading through arith.c, I notice that gfc_range_check()
> contained the snippet:
>
> case BT_COMPLEX:
> rc = gfc_check_real_range (e->value.complex.r, e->ts.kind);
> if (rc != ARITH_OK)
> rc = gfc_check_real_range (e->value.complex.i, e->ts.kind);
>
> where gfc_range_check() supposely checks that the "constant numeric
> expression is within the range for its type and kind.". Suppose,
> we somehow have a complex number of (1e50, 1.). The first call
> will set rc = ARITH_OVERFLOW, and then the expression in the
> if () is true. The second call to gfc_check_real_range will return
> ARITH_OK. So, gfc_check_real_range() will return ARITH_OK, which
> 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
2004-05-16 Paul Brook <paul@codesourcery.com>
* arith.c (gfc_range_check): Fix logic error.
Index: arith.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/arith.c,v
retrieving revision 1.4
diff -u -p -r1.4 arith.c
--- arith.c 16 May 2004 11:26:25 -0000 1.4
+++ arith.c 16 May 2004 18:00:02 -0000
@@ -1193,7 +1193,7 @@ gfc_range_check (gfc_expr * e)
case BT_COMPLEX:
rc = gfc_check_real_range (e->value.complex.r, e->ts.kind);
- if (rc != ARITH_OK)
+ if (rc == ARITH_OK)
rc = gfc_check_real_range (e->value.complex.i, e->ts.kind);
break;
More information about the Fortran
mailing list