public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/104350] ICE in gfc_array_dimen_size(): Bad dimension
Date: Fri, 25 Feb 2022 20:27:10 +0000	[thread overview]
Message-ID: <bug-104350-4-FD5pnYUp0R@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104350-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104350

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-02-25

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

There are multiple ways to avoid the ICE:

- replace gfc_internal_error in gfc_array_dimen_size by gfc_error, e.g.

diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
index f1d92e00c98..a42fb8f59fe 100644
--- a/gcc/fortran/array.cc
+++ b/gcc/fortran/array.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "options.h"
 #include "gfortran.h"
 #include "parse.h"
+#include "intrinsic.h"
 #include "match.h"
 #include "constructor.h"

@@ -2571,7 +2572,13 @@ gfc_array_dimen_size (gfc_expr *array, int dimen, mpz_t
*result)
     return false;

   if (dimen < 0 || dimen > array->rank - 1)
-    gfc_internal_error ("gfc_array_dimen_size(): Bad dimension");
+    {
+      gfc_error ("DIM argument (%d) to intrinsic %qs at %L out of range "
+                "(1:%d)", dimen+1, gfc_current_intrinsic,
+                gfc_current_intrinsic_where, array->rank);
+      return false;
+    }
+//    gfc_internal_error ("gfc_array_dimen_size(): Bad dimension");

   switch (array->expr_type)
     {

This however produces two error messages of the kind:

pr104350-z1.f90:4:21:

    4 |   print *, product([(size(x, dim=k), k=0,rank(x))])
      |                     1
Error: DIM argument (0) to intrinsic 'size' at (1) out of range (1:1)
pr104350-z1.f90:4:10:

    4 |   print *, product([(size(x, dim=k), k=0,rank(x))])
      |          1
Error: DIM argument (0) to intrinsic 'product' at (1) out of range (1:1)

The second error is misleading. :-(

- a similar patch to simplify_size generates a similar error twice.  :-(

  reply	other threads:[~2022-02-25 20:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 18:41 [Bug fortran/104350] New: " gscfq@t-online.de
2022-02-25 20:27 ` anlauf at gcc dot gnu.org [this message]
2023-05-23 20:51 ` [Bug fortran/104350] " anlauf at gcc dot gnu.org
2023-05-24 19:16 ` anlauf at gcc dot gnu.org
2023-05-24 19:51 ` cvs-commit at gcc dot gnu.org
2023-05-25 17:14 ` anlauf at gcc dot gnu.org

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=bug-104350-4-FD5pnYUp0R@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).