From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AAD39385AC37; Tue, 25 Oct 2022 21:44:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAD39385AC37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666734250; bh=OHD0KNr7V66WSUdZZrMowCVYRKuMtcFh8nMtiIMXqU8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WgSvZZgPx+h9dLZWdfIjq7oWKhvwH59TLlGUDw1wXhfJCZ3fVgXeiH27mC6R2ueMv FjPOChmCe/xJ5LIn8MU8gqbLhF91tZVrwX+9/lh1deFirgj4gWZa9yDYFdxneToWGv VSqAOwD15C+5/EnqOxIBIC5QUnhbSaXI3hesz9lI= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/103413] [10/11/12/13 Regression] ICE: Invalid expression in gfc_element_size since r10-2083-g8dc63166e0b85954 Date: Tue, 25 Oct 2022 21:44:01 +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: 12.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: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D103413 --- Comment #10 from kargl at gcc dot gnu.org --- (In reply to anlauf from comment #9) > Steve, >=20 > what do you think about the following patch? Not yet fully regtested. > It should fix the issue much simpler by checking type compatibility: >=20 > diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc > index 6050359d521..f4052eb7042 100644 > --- a/gcc/fortran/symbol.cc > +++ b/gcc/fortran/symbol.cc > @@ -5139,6 +5141,9 @@ gfc_type_compatible (gfc_typespec *ts1, gfc_typespec > *ts2) > bool is_union1 =3D (ts1->type =3D=3D BT_UNION); > bool is_union2 =3D (ts2->type =3D=3D BT_UNION); >=20=20 > + if (ts2->type =3D=3D BT_BOZ) > + return (ts1->type =3D=3D BT_INTEGER || ts1->type =3D=3D BT_REAL); > + > if (is_class1 > && ts1->u.derived->components > && ((ts1->u.derived->attr.is_class >=20 > Do you have a testcase that exercises BT_INTEGER and BT_REAL here? > I thought that one of the pathes that reaches gfc_boz2int and gfc_boz2real > might need the above. Well, a boz is typeless, so it cannot be compatible with any other type. So, I would assume, you could do=20 if (ts1->type =3D=3D BT_BOZ || ts2->type =3D=3D BT_BOZ) return false; There is a caveat in that Fortran 2023 is going to allow things like real :: x =3D z'1234' if gfc_type_compatible is used in simple assignments, gfortran will need to deal with that.=