public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10433] Fortran: error recovery when simplifying EOSHIFT Date: Wed, 2 Feb 2022 19:54:11 +0000 (GMT) [thread overview] Message-ID: <20220202195411.051143858D37@sourceware.org> (raw) https://gcc.gnu.org/g:323e72a83d417b230c2d93455fa09a4b66614c2a commit r10-10433-g323e72a83d417b230c2d93455fa09a4b66614c2a Author: Harald Anlauf <anlauf@gmx.de> Date: Tue Feb 1 21:36:42 2022 +0100 Fortran: error recovery when simplifying EOSHIFT gcc/fortran/ChangeLog: PR fortran/104331 * simplify.c (gfc_simplify_eoshift): Avoid NULL pointer dereference when shape is not set. gcc/testsuite/ChangeLog: PR fortran/104331 * gfortran.dg/eoshift_9.f90: New test. (cherry picked from commit 447047a8f95c6bf4b1873f390c833e91aa8af18c) Diff: --- gcc/fortran/simplify.c | 3 +++ gcc/testsuite/gfortran.dg/eoshift_9.f90 | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index bce6f066ee6..f0f322c1caf 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -2540,6 +2540,9 @@ gfc_simplify_eoshift (gfc_expr *array, gfc_expr *shift, gfc_expr *boundary, if (arraysize == 0) goto final; + if (array->shape == NULL) + goto final; + arrayvec = XCNEWVEC (gfc_expr *, arraysize); array_ctor = gfc_constructor_first (array->value.constructor); for (i = 0; i < arraysize; i++) diff --git a/gcc/testsuite/gfortran.dg/eoshift_9.f90 b/gcc/testsuite/gfortran.dg/eoshift_9.f90 new file mode 100644 index 00000000000..f711b04a7da --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eoshift_9.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/104331 - ICE in gfc_simplify_eoshift +! Contributed by G.Steinmetz + +program p + character(3), parameter :: a(:) = ['123'] ! { dg-error "deferred shape" } + character(3), parameter :: b(*) = eoshift(a, 1) +end
reply other threads:[~2022-02-02 19:54 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=20220202195411.051143858D37@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).