From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D3F7C385D0EB; Wed, 26 Oct 2022 14:07:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3F7C385D0EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666793263; bh=y+S/WKseFJJssBJTf8qG3HPXbGofsP7HriA4jO6mpEA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=huBBgKayW0SfufhfOW5M8Gv4WlRTAlvlHsaxHT5quvsG3K1xQ5vxREL65M5MMJr3C tYp0wC0DWDc8DypOSZVt65q3/DWANNdSAcCPi+Y5qS09eAa+43P6VdNKXKmFjpwmZz AD8dTGpJZ6P/iCsl2p/6EeeywW5vqnxFfwflFS6A= From: "kargl at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: priority cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107397 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 =3D init->ts.f90_type; } + /* Catch the case: type(t), parameter :: x =3D z'1'. */ + if (sym->ts.type =3D=3D BT_DERIVED && init->ts.type =3D=3D 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 =3D=3D 0) {=