This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] PR33609 ICE on arithmetic overflow


Hi,

The ICE is caused by a NULL pointer returned by arith.c (gfc_real2real) when error condition is detected:

 else if (rc != ARITH_OK)
 {
 arith_error (rc, &src->ts, &result->ts, &src->where);
 gfc_free_expr (result);
 return NULL;
 }

Execution then goes back to the caller gfc_simplify_real which then does:

return range_check (result, "REAL");

The segfault occurs in range_check.

I will commit the following patch as obvious. Test case attached.

Regression tested on x86-64-Gnu-linux.

Jerry

Index: simplify.c
===================================================================
--- simplify.c (revision 129029)
+++ simplify.c (working copy)
@@ -70,6 +70,9 @@ gfc_expr gfc_bad_expr;
 static gfc_expr *
 range_check (gfc_expr *result, const char *name)
 {
+ if (result == NULL)
+ return &gfc_bad_expr;
+
 switch (gfc_range_check (result))
 {
 case ARITH_OK:

2007年10月06日 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR fortran/33609
	* simplify.c (range_check): Return gfc_bad_expr if incoming expression
	is NULL.
! { dg-do compile }
! PR33609 ICE on arithmetic overflow
! Before patch, this segfaulted.
print *, real(huge(1.0_8),4) ! { dg-error "Arithmetic overflow" }
end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

AltStyle によって変換されたページ (->オリジナル) /