public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jvdelisle at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/103506] [10/11/12/13 Regression] ICE in gfc_free_namespace, at fortran/symbol.c:4039 since r10-2798-ge68a35ae4a65d2b3
Date: Sun, 29 Jan 2023 03:08:12 +0000	[thread overview]
Message-ID: <bug-103506-4-9eBv6v7OEm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103506-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103506

--- Comment #14 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
This is interesting. Simply doing the following eliminates the ice.

diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index 0fb19cc9f0f..a9e538cc2a1 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -6544,8 +6544,6 @@ loop:
     default:
       gfc_error ("Unexpected %s statement in MODULE at %C",
                 gfc_ascii_statement (st));
-
-      error = true;
       reject_statement ();
       st = next_statement ();
       goto loop;

I discovered this studying other code that was rejecting statements and found
the following existing function:

/* Generic complaint about an out of order statement.  We also do
   whatever is necessary to clean up.  */

static void
unexpected_statement (gfc_statement st)
{
  gfc_error ("Unexpected %s statement at %C", gfc_ascii_statement (st));

  reject_statement ();
}

I tried it at the location of the patch just above and it worked. The error
message is generic but no ice.  In fact the only difference is setting
error=true.

With the generic error message there are a couple of existing test cases that
don't pass but these would be minor edits.

All this begs the question about why set error=true.  Right after this the code
on parse.cc has:

  /* Make sure not to free the namespace twice on error.  */
  if (!error)
    s->ns = gfc_current_ns;

Well, setting it true s->ns is not getting set at all. Meaning it is left
uninitialized.  The comment about freeing the namespace is also bogus here.
There is no freeing of anything in this chunk of code.

  parent reply	other threads:[~2023-01-29  3:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 18:49 [Bug fortran/103506] New: [10/11/12 Regression] ICE in gfc_free_namespace, at fortran/symbol.c:4039 gscfq@t-online.de
2021-12-01  7:17 ` [Bug fortran/103506] " rguenth at gcc dot gnu.org
2021-12-01  9:28 ` [Bug fortran/103506] [10/11/12 Regression] ICE in gfc_free_namespace, at fortran/symbol.c:4039 since r10-2798-ge68a35ae4a65d2b3 marxin at gcc dot gnu.org
2021-12-22 23:52 ` kargl at gcc dot gnu.org
2022-06-28 10:47 ` [Bug fortran/103506] [10/11/12/13 " jakub at gcc dot gnu.org
2022-06-28 14:59 ` kargl at gcc dot gnu.org
2023-01-26  2:56 ` jvdelisle at gcc dot gnu.org
2023-01-26 18:29 ` sgk at troutmask dot apl.washington.edu
2023-01-27  2:06 ` jvdelisle at gcc dot gnu.org
2023-01-27  2:11 ` jvdelisle at gcc dot gnu.org
2023-01-27  2:14 ` jvdelisle at gcc dot gnu.org
2023-01-27 17:28 ` sgk at troutmask dot apl.washington.edu
2023-01-27 21:33 ` anlauf at gcc dot gnu.org
2023-01-27 21:52 ` tkoenig at gcc dot gnu.org
2023-01-28  0:59 ` jvdelisle at gcc dot gnu.org
2023-01-29  3:08 ` jvdelisle at gcc dot gnu.org [this message]
2023-01-29 19:10 ` cvs-commit at gcc dot gnu.org
2023-03-22 18:18 ` [Bug fortran/103506] [10/11/12 " anlauf at gcc dot gnu.org
2023-03-27  1:17 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:41 ` [Bug fortran/103506] [11/12 " rguenth at gcc dot gnu.org
2023-07-08 19:43 ` [Bug fortran/103506] [11 " anlauf at gcc dot gnu.org
2023-08-05 23:44 ` cvs-commit at gcc dot gnu.org
2023-08-05 23:45 ` jvdelisle at gcc dot gnu.org

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=bug-103506-4-9eBv6v7OEm@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).