This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] PR33609 ICE on arithmetic overflow
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 06 Oct 2007 16:39:18 -0700
- Subject: [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