public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Thomas Koenig <tkoenig@gcc.gnu.org>
Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org
Subject: [PATCH] Fix Fortran ICE due to realloc_string_callback bug (PR fortran/71204)
Date: Fri, 20 May 2016 11:36:00 -0000	[thread overview]
Message-ID: <20160520113610.GJ28550@tucnak.redhat.com> (raw)

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

             reply	other threads:[~2016-05-20 11:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 11:36 Jakub Jelinek [this message]
2016-05-20 17:50 ` Thomas Koenig
2016-05-20 20:16 ` Jerry DeLisle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160520113610.GJ28550@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tkoenig@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).