public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/107397] [10/11/12/13 Regression] ICE in gfc_arith_plus, at fortran/arith.cc:654
Date: Wed, 26 Oct 2022 14:07:42 +0000	[thread overview]
Message-ID: <bug-107397-4-Nix2KTRzUo@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107397-4@http.gcc.gnu.org/bugzilla/>

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org ---
Interesting bug.  The BOZ on the rhs is eventually rejected,
but if any error/warning that might be queued is lost during
a pass through  add_init_expr_to_sym().  Eventually, the rhs
expr is freed and the pointer to the initializer is wrong.

This patch fixes the ICE and issues an error.  It has passed
regression testing.

diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 0f9b2ced4c2..1562dc22bc6 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -2221,6 +2221,14 @@ add_init_expr_to_sym (const char *name, gfc_expr
**initp, locus *var_locus)
            sym->ts.f90_type = init->ts.f90_type;
        }

+      /* Catch the case:  type(t), parameter :: x = z'1'.  */
+      if (sym->ts.type == BT_DERIVED && init->ts.type == BT_BOZ)
+       {
+         gfc_error ("Entity %qs at %L is incompatible with a BOZ "
+                    "literal constant", name, &sym->declared_at);
+         return false;
+       }
+
       /* Add initializer.  Make sure we keep the ranks sane.  */
       if (sym->attr.dimension && init->rank == 0)
        {

  parent reply	other threads:[~2022-10-26 14:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 17:29 [Bug fortran/107397] New: " gscfq@t-online.de
2022-10-25 18:21 ` [Bug fortran/107397] " anlauf at gcc dot gnu.org
2022-10-25 19:31 ` marxin at gcc dot gnu.org
2022-10-26 14:07 ` kargl at gcc dot gnu.org [this message]
2022-10-28 11:12 ` rguenth at gcc dot gnu.org
2022-10-28 20:31 ` anlauf at gcc dot gnu.org
2022-10-28 21:43 ` sgk at troutmask dot apl.washington.edu
2022-10-28 21:51 ` anlauf at gcc dot gnu.org
2022-10-29 19:09 ` anlauf at gcc dot gnu.org
2022-12-18  3:39 ` cvs-commit at gcc dot gnu.org
2022-12-18 12:18 ` rimvydas.jas at gmail dot com
2022-12-18 12:19 ` rimvydas.jas at gmail dot com
2022-12-19 10:35 ` cvs-commit at gcc dot gnu.org
2023-01-17 20:49 ` [Bug fortran/107397] [10/11/12 " anlauf at gcc dot gnu.org
2023-07-07 10:44 ` [Bug fortran/107397] [11/12 " rguenth at gcc dot gnu.org
2023-07-07 20:30 ` anlauf at gcc dot gnu.org
2023-08-05 23:52 ` jvdelisle at gcc dot gnu.org
2023-08-06  0:34 ` cvs-commit at gcc dot gnu.org
2023-08-06  0:34 ` cvs-commit at gcc dot gnu.org
2023-08-06  0:54 ` cvs-commit at gcc dot gnu.org
2023-08-06  0:54 ` cvs-commit at gcc dot gnu.org
2023-08-06  1:04 ` jvdelisle 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-107397-4-Nix2KTRzUo@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).