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 r12-5635] Fortran: error recovery when simplifying MINLOC/MAXLOC Date: Tue, 30 Nov 2021 19:39:32 +0000 (GMT) [thread overview] Message-ID: <20211130193932.1998B385BF80@sourceware.org> (raw) https://gcc.gnu.org/g:36421e76a7150621f2a5c7060ddd3f80aa825a40 commit r12-5635-g36421e76a7150621f2a5c7060ddd3f80aa825a40 Author: Harald Anlauf <anlauf@gmx.de> Date: Mon Nov 29 22:56:30 2021 +0100 Fortran: error recovery when simplifying MINLOC/MAXLOC gcc/fortran/ChangeLog: PR fortran/103473 * simplify.c (simplify_minmaxloc_nodim): Avoid NULL pointer dereference when shape is not set. gcc/testsuite/ChangeLog: PR fortran/103473 * gfortran.dg/minmaxloc_15.f90: New test. Diff: --- gcc/fortran/simplify.c | 3 +++ gcc/testsuite/gfortran.dg/minmaxloc_15.f90 | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index c9e13b59da9..fb7b7814603 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -5280,6 +5280,9 @@ simplify_minmaxloc_nodim (gfc_expr *result, gfc_expr *extremum, && !mask->value.logical) goto finish; + if (array->shape == NULL) + goto finish; + for (i = 0; i < array->rank; i++) { count[i] = 0; diff --git a/gcc/testsuite/gfortran.dg/minmaxloc_15.f90 b/gcc/testsuite/gfortran.dg/minmaxloc_15.f90 new file mode 100644 index 00000000000..e4eba3501d5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/minmaxloc_15.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/103473 - ICE in simplify_minmaxloc_nodim +! Test case by Gerhard Steinmetz. + +subroutine s + implicit none + integer, parameter :: a(+'1') = [1] ! { dg-error "unary numeric operator" } + print *, minloc (a) +end + +! { dg-prune-output "Parameter array" }
reply other threads:[~2021-11-30 19:39 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=20211130193932.1998B385BF80@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).