From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] PR fortran/105230 - [9/10/11/12/13 Regression] ICE in find_array_section, at fortran/expr.cc:1634
Date: Tue, 10 May 2022 23:51:50 +0200 [thread overview]
Message-ID: <trinity-a629fb14-9303-4019-9ede-0b83fbde9456-1652219510387@3c-app-gmx-bap27> (raw)
[-- Attachment #1: Type: text/plain, Size: 377 bytes --]
Dear all,
I intend to commit the attached patch as obvious within the next
24 hours unless there are objections. It fixes the logic which
is intended to prevent a NULL pointer dereference on invalid
code, which is related to PR104849. (Both PRs by Gerhard).
Co-authored by Steve. Regtested on x86_64-pc-linux-gnu.
I plan to backport as seems appropriate.
Thanks,
Harald
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fortran-fix-error-recovery-on-invalid-array-section.patch --]
[-- Type: text/x-patch, Size: 1763 bytes --]
From eac44ace68dd0476bda93ea49a758904c30e3a33 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Tue, 10 May 2022 23:41:57 +0200
Subject: [PATCH] Fortran: fix error recovery on invalid array section
gcc/fortran/ChangeLog:
PR fortran/105230
* expr.cc (find_array_section): Correct logic to avoid NULL
pointer dereference on invalid array section.
gcc/testsuite/ChangeLog:
PR fortran/105230
* gfortran.dg/pr105230.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
---
gcc/fortran/expr.cc | 4 ++--
gcc/testsuite/gfortran.dg/pr105230.f90 | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/pr105230.f90
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 != EXPR_CONSTANT)
|| (finish && finish->expr_type != EXPR_CONSTANT)
|| (step && step->expr_type != EXPR_CONSTANT)
- || (!begin && !lower)
- || (!finish && !upper))
+ || !lower
+ || !upper)
{
t = false;
goto cleanup;
diff --git a/gcc/testsuite/gfortran.dg/pr105230.f90 b/gcc/testsuite/gfortran.dg/pr105230.f90
new file mode 100644
index 00000000000..6c6b42ef9bf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr105230.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/105230 - ICE in find_array_section
+! Contributed by G.Steinmetz
+
+program p
+ integer, parameter :: a(:) = [1, 2] ! { dg-error "deferred shape" }
+ print *, reshape([3, 4], a(1:2))
+end
--
2.35.3
reply other threads:[~2022-05-10 21:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=trinity-a629fb14-9303-4019-9ede-0b83fbde9456-1652219510387@3c-app-gmx-bap27 \
--to=anlauf@gmx.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@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).