public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/105230] [9/10/11/12 Regression] ICE in find_array_section, at fortran/expr.cc:1634
Date: Mon, 11 Apr 2022 17:47:37 +0000	[thread overview]
Message-ID: <bug-105230-4-LqvGSpuH1q@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105230-4@http.gcc.gnu.org/bugzilla/>

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-04-11
                 CC|                            |kargl at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from kargl at gcc dot gnu.org ---
Started with 22015e77d3e4.

I cannot work out the logic here in expr.cc:1595-1603


          if ((begin && begin->expr_type != EXPR_CONSTANT)
              || (finish && finish->expr_type != EXPR_CONSTANT)
              || (step && step->expr_type != EXPR_CONSTANT)
              || (!begin && !lower)
              || (!finish && !upper))
            {
              t = false;
              goto cleanup;
            }

upper is NULL and later in 1634 it is dereferenced.  This patch fixes
the problem, but the above logic likely needs fixing.

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 86d61fed302..4fcdf009b4b 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1630,6 +1630,11 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
          if (ref->u.ar.dimen_type[d] == DIMEN_ELEMENT)
            mpz_set (end [d], begin->value.integer);

+         if (!upper || !lower)
+           {
+             t = false;
+             goto cleanup;
+           }
          /* Check the bounds.  */
          if (mpz_cmp (ctr[d], upper->value.integer) > 0
              || mpz_cmp (end[d], upper->value.integer) > 0

  reply	other threads:[~2022-04-11 17:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 16:57 [Bug fortran/105230] New: " gscfq@t-online.de
2022-04-11 17:47 ` kargl at gcc dot gnu.org [this message]
2022-04-12  7:43 ` [Bug fortran/105230] " rguenth at gcc dot gnu.org
2022-05-10 19:02 ` [Bug fortran/105230] [9/10/11/12/13 " anlauf at gcc dot gnu.org
2022-05-11 17:44 ` cvs-commit at gcc dot gnu.org
2022-05-13 19:35 ` cvs-commit at gcc dot gnu.org
2022-05-16 19:11 ` cvs-commit at gcc dot gnu.org
2022-05-16 19:40 ` cvs-commit at gcc dot gnu.org
2022-05-16 20:05 ` cvs-commit at gcc dot gnu.org
2022-05-16 20:07 ` anlauf 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-105230-4-LqvGSpuH1q@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).