From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B04A83858D38; Sun, 28 May 2023 15:29:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B04A83858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685287771; bh=xOiGYJvC0cM3HGGz+FcHXWhCiLeggIsvvYbrnteUZmQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cFsihLyt+wPGxwn/sfhMZgODC2k/ztq/FVV8GcTLApmrFlVv13PvAbslai9tavbFy PqSHFikgy2T1tGd2vl/UPhOYlObduZZRUnSPfyjzH9NjvsDsBeeYNkmvgDnpJYLyxY 3ZxJZbAXBWQM5tf1MG4TK/eDKTMX5B1ZPuPfKXzI= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99139] ICE: gfc_get_default_type(): Bad symbol '__tmp_UNKNOWN_0_rank_1' Date: Sun, 28 May 2023 15:29:30 +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: 11.0 X-Bugzilla-Keywords: ice-on-valid-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: 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=3D99139 --- Comment #5 from kargl at gcc dot gnu.org --- (In reply to sandra from comment #4) > The problem noted in comment 1 looks related to PR 102641 -- > automatically-inserted implicit initialization code can't cope with > assumed-rank arrays. I don't think it is related. PR102601 involves default initialization and/or deallocation of an actual argument associated with an intent(out) assumed-rank dummy argument. > I tested the patch in comment 2 and saw a whole lot of regressions (ICEs)= .=20 > :-( The patch in comment #2 needed to be moved down into the 'if (m =3D=3D MATC= H_YES)' block where 'expr2 !=3D NULL'. The following has been regtested with no new regressions. diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 5eb6d0e1c1d..0a030ae01df 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -6770,8 +6770,20 @@ gfc_match_select_rank (void) gfc_current_ns =3D gfc_build_block_ns (ns); m =3D gfc_match (" %n =3D> %e", name, &expr2); + if (m =3D=3D MATCH_YES) { + /* If expr2 corresponds to an implicitly typed variable, then the + actual type of the variable may not have been set. Set it here. = */ + if (!gfc_current_ns->seen_implicit_none=20 + && expr2->expr_type =3D=3D EXPR_VARIABLE + && expr2->ts.type =3D=3D BT_UNKNOWN + && expr2->symtree && expr2->symtree->n.sym) + { + gfc_set_default_type (expr2->symtree->n.sym, 0, gfc_current_ns); + expr2->ts.type =3D expr2->symtree->n.sym->ts.type; + }=20=20=20=20 + expr1 =3D gfc_get_expr (); expr1->expr_type =3D EXPR_VARIABLE; expr1->where =3D expr2->where;=