public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jrfsousa at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/91726] [8/9 Regression] ICE in gfc_conv_array_ref, at fortran/trans-array.c:3612
Date: Thu, 01 Apr 2021 18:19:32 +0000	[thread overview]
Message-ID: <bug-91726-4-EiGtgPPVPl@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-91726-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #9 from José Rui Faustino de Sousa <jrfsousa at gmail dot com> ---
Hi Paul!

This seems to fix the ICE generated by using -ftrapv -fcheck=bounds

Fixes "nelems" type and adds an optional assert to make sure it stays fixed.

Best regards,
José Rui


diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index be5eb89350f..7954b138605 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -9375,7 +9375,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
                                                        nelems));
                }
              else
-               nelems = build_int_cst (size_type_node, 1);
+               nelems = build_int_cst (gfc_array_index_type, 1);

              if (CLASS_DATA (c)->attr.dimension
                  || CLASS_DATA (c)->attr.codimension)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 2fa17b36c03..258e885faaa 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -1446,6 +1452,7 @@ gfc_copy_class_to_class (tree from, tree to, tree nelems,
bool unlimited)
            name = (const char *)(DECL_NAME (to)->identifier.id.str);

          from_len = gfc_conv_descriptor_size (from_data, 1);
+         gcc_assert (TREE_TYPE (orig_nelems) == gfc_array_index_type);
          tmp = fold_build2_loc (input_location, NE_EXPR,
                                  logical_type_node, from_len, orig_nelems);
          msg = xasprintf ("Array bound mismatch for dimension %d "

  parent reply	other threads:[~2021-04-01 18:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-91726-4@http.gcc.gnu.org/bugzilla/>
2020-05-06 13:14 ` jrfsousa at gmail dot com
2021-01-08 18:40 ` pault at gcc dot gnu.org
2021-04-01 18:19 ` jrfsousa at gmail dot com [this message]
2021-05-14  9:52 ` [Bug fortran/91726] [9 " jakub at gcc dot gnu.org
2021-06-01  8:15 ` rguenth at gcc dot gnu.org
2022-05-27  8:38 ` rguenth 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-91726-4-EiGtgPPVPl@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).