From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DE2733856276; Tue, 10 May 2022 19:02:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE2733856276 From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/105230] [9/10/11/12/13 Regression] ICE in find_array_section, at fortran/expr.cc:1634 Date: Tue, 10 May 2022 19:02:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 19:02:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105230 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- (In reply to kargl from comment #1) > Started with 22015e77d3e4. No, it didn't start with that commit. That commit missed the present situation. The ICE is pre-existing. > upper is NULL and later in 1634 it is dereferenced. This patch fixes > the problem, but the above logic likely needs fixing. That's right. Shorter fix: diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 86d61fed302..be94c18c836 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1595,8 +1595,8 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) if ((begin && begin->expr_type !=3D EXPR_CONSTANT) || (finish && finish->expr_type !=3D EXPR_CONSTANT) || (step && step->expr_type !=3D EXPR_CONSTANT) - || (!begin && !lower) - || (!finish && !upper)) + || !lower + || !upper) { t =3D false; goto cleanup;=