[PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204)
Jakub Jelinek
jakub@redhat.com
Fri May 20 11:36:00 GMT 2016
Hi!
We ICE at -O0 while compiling the testcase below, because we don't reset
two vars that are reset in all other places in frontend-passes.c when
starting to process an unrelated statement. Without this,
we can emit some statement into a preexisting block that can be elsewhere
in the current procedure or as in the testcase in completely different
procedure.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/6/5?
2016-05-20 Jakub Jelinek <jakub@redhat.com>
PR fortran/71204
* frontend-passes.c (realloc_string_callback): Clear inserted_block
and changed_statement before calling create_var.
* gfortran.dg/pr71204.f90: New test.
--- gcc/fortran/frontend-passes.c.jj 2016-05-11 15:16:18.000000000 +0200
+++ gcc/fortran/frontend-passes.c 2016-05-20 10:44:31.699542384 +0200
@@ -174,8 +174,10 @@ realloc_string_callback (gfc_code **c, i
if (!gfc_check_dependency (expr1, expr2, true))
return 0;
-
+
current_code = c;
+ inserted_block = NULL;
+ changed_statement = NULL;
n = create_var (expr2, "trim");
co->expr2 = n;
return 0;
--- gcc/testsuite/gfortran.dg/pr71204.f90.jj 2016-05-20 10:45:40.738608941 +0200
+++ gcc/testsuite/gfortran.dg/pr71204.f90 2016-05-20 10:46:25.873998687 +0200
@@ -0,0 +1,17 @@
+! PR fortran/71204
+! { dg-do compile }
+! { dg-options "-O0" }
+
+module pr71204
+ character(10), allocatable :: z(:)
+end module
+
+subroutine s1
+ use pr71204
+ z(2) = z(1)
+end
+
+subroutine s2
+ use pr71204
+ z(2) = z(1)
+end
Jakub
More information about the Fortran
mailing list