public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH, committed] Fortran: ICE in gfc_compare_array_spec [PR108528]
Date: Wed, 25 Jan 2023 20:53:36 +0100	[thread overview]
Message-ID: <trinity-e58ca35d-9f14-4c23-a70e-c307739ee6ed-1674676416042@3c-app-gmx-bs46> (raw)

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

Dear all,

I've committed the attached simple and obvious patch by
Steve after regtesting on x86_64-pc-linux-gnu.
Instead of generating an internal error when wrong types
are passed to a bounds comparison, simply return false.

Committed:
https://gcc.gnu.org/g:9fb9da3d38513d320bfea72050f7a59688595e0b

Thanks,
Harald


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr108528.diff --]
[-- Type: text/x-patch, Size: 2270 bytes --]

From 9fb9da3d38513d320bfea72050f7a59688595e0b Mon Sep 17 00:00:00 2001
From: Steve Kargl <kargl@gcc.gnu.org>
Date: Wed, 25 Jan 2023 20:38:43 +0100
Subject: [PATCH] Fortran: ICE in gfc_compare_array_spec [PR108528]

gcc/fortran/ChangeLog:

	PR fortran/108528
	* array.cc (compare_bounds): Return false instead of generating an
	internal error on an invalid argument type.

gcc/testsuite/ChangeLog:

	PR fortran/108528
	* gfortran.dg/pr108528.f90: New test.
---
 gcc/fortran/array.cc                   | 4 ++--
 gcc/testsuite/gfortran.dg/pr108528.f90 | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr108528.f90

diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
index e8a2c32a627..be5eb8b6a0f 100644
--- a/gcc/fortran/array.cc
+++ b/gcc/fortran/array.cc
@@ -967,7 +967,7 @@ gfc_copy_array_spec (gfc_array_spec *src)
 
 
 /* Returns nonzero if the two expressions are equal.
-   We should not need to support more than constant values, as that’s what is
+   We should not need to support more than constant values, as that's what is
    allowed in derived type component array spec.  However, we may create types
    with non-constant array spec for dummy variable class container types, for
    which the _data component holds the array spec of the variable declaration.
@@ -979,7 +979,7 @@ compare_bounds (gfc_expr *bound1, gfc_expr *bound2)
   if (bound1 == NULL || bound2 == NULL
       || bound1->ts.type != BT_INTEGER
       || bound2->ts.type != BT_INTEGER)
-    gfc_internal_error ("gfc_compare_array_spec(): Array spec clobbered");
+    return false;
 
   /* What qualifies as identical bounds?  We could probably just check that the
      expressions are exact clones.  We avoid rewriting a specific comparison
diff --git a/gcc/testsuite/gfortran.dg/pr108528.f90 b/gcc/testsuite/gfortran.dg/pr108528.f90
new file mode 100644
index 00000000000..7a353cb7eab
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108528.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/108528 -
+! Contributed by G.Steinmetz
+
+function f()         ! { dg-error "mismatched array specifications" }
+  integer :: f((2.)) ! { dg-error "must be of INTEGER type" }
+  integer :: g((2))
+entry g()
+end
-- 
2.35.3


                 reply	other threads:[~2023-01-25 19:53 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-e58ca35d-9f14-4c23-a70e-c307739ee6ed-1674676416042@3c-app-gmx-bs46 \
    --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).