* [PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204)
@ 2016-05-20 11:36 Jakub Jelinek
2016-05-20 17:50 ` Thomas Koenig
2016-05-20 20:16 ` Jerry DeLisle
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2016-05-20 11:36 UTC (permalink / raw)
To: Thomas Koenig; +Cc: gcc-patches, fortran
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204)
2016-05-20 11:36 [PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204) Jakub Jelinek
@ 2016-05-20 17:50 ` Thomas Koenig
2016-05-20 20:16 ` Jerry DeLisle
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Koenig @ 2016-05-20 17:50 UTC (permalink / raw)
To: Jakub Jelinek, Thomas Koenig; +Cc: gcc-patches, fortran
Hi Jakub,
>
> 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?
OK for all affected branches.
Thanks for the patch!
Thomas
[I am currently extremely busy in Real Life (TM), sorry for not taking
this on myself].
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204)
2016-05-20 11:36 [PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204) Jakub Jelinek
2016-05-20 17:50 ` Thomas Koenig
@ 2016-05-20 20:16 ` Jerry DeLisle
1 sibling, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2016-05-20 20:16 UTC (permalink / raw)
To: Jakub Jelinek, Thomas Koenig; +Cc: gcc-patches, fortran
On 05/20/2016 04:36 AM, Jakub Jelinek wrote:
> 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?
Yes, OK, thanks for patch!
Jerry
>
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-20 20:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20 11:36 [PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204) Jakub Jelinek
2016-05-20 17:50 ` Thomas Koenig
2016-05-20 20:16 ` 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).