* [patch, fortran] PR33609 ICE on arithmetic overflow
@ 2007-10-06 23:40 Jerry DeLisle
0 siblings, 0 replies; only message in thread
From: Jerry DeLisle @ 2007-10-06 23:40 UTC (permalink / raw)
To: Fortran List; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]
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.
[-- Attachment #2: error_recovery_4.f90 --]
[-- Type: text/x-fortran, Size: 160 bytes --]
! { dg-do compile }
! PR33609 ICE on arithmetic overflow
! Before patch, this segfaulted.
print *, real(huge(1.0_8),4) ! { dg-error "Arithmetic overflow" }
end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-10-06 23:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-06 23:40 [patch, fortran] PR33609 ICE on arithmetic overflow Jerry DeLisle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).