From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6CC51384AB47; Fri, 3 May 2024 07:16:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CC51384AB47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714720572; bh=m8DXvZ7fnPfQRl7zIQcq0WYo7EB3klEghKSb3uRwbeU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UUp6A7b/ESXlrlJIVRDLulhgdXqT6ufYXM1o6uwMEgXSalpJ3J6lzz6DwN4tn5Rcf cn1W0lolxGFgVLAsWRtNGNb4SoB6g9v3tBjgi3GvOO3/RnuQN9rjJ8rt4JLcaSTPSp XLRVjQtgIKDx6tZKaovMJ6GLJYnxU2/j0nr7NY/w= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23 Date: Fri, 03 May 2024 07:16:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D114931 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #7 from Richard Biener --- I'll note that seeing code like the following which possibly mutates existi= ng hash entries looks quite broken. But of course type_hash_canon is a fragile bit of code (well, it shouldn't ...). To me it looks like we should compute and set the canonical type first and _then_ do the hash lookup (which should include the canonical type). And I'd make type_hash_canon take a tree * to modify, making its return value a bool whether we found an existing type so we can simply do if (type_hash_canon (hash, &t)) { ggc_free (orig_t); retur= n t; } tree build_function_type (tree value_type, tree arg_types, bool no_named_args_stdarg_p) { tree t; inchash::hash hstate; bool any_structural_p, any_noncanonical_p; tree canon_argtypes; gcc_assert (arg_types !=3D error_mark_node); if (TREE_CODE (value_type) =3D=3D FUNCTION_TYPE) { error ("function return type cannot be function"); value_type =3D integer_type_node; } /* Make a node of the sort we want. */ t =3D make_node (FUNCTION_TYPE); TREE_TYPE (t) =3D value_type; TYPE_ARG_TYPES (t) =3D arg_types; if (no_named_args_stdarg_p) { gcc_assert (arg_types =3D=3D NULL_TREE); TYPE_NO_NAMED_ARGS_STDARG_P (t) =3D 1; } /* If we already have such a type, use the old one. */ hashval_t hash =3D type_hash_canon_hash (t); t =3D type_hash_canon (hash, t); /* Set up the canonical type. */ any_structural_p =3D TYPE_STRUCTURAL_EQUALITY_P (value_type); any_noncanonical_p =3D TYPE_CANONICAL (value_type) !=3D value_type; canon_argtypes =3D maybe_canonicalize_argtypes (arg_types, &any_structural_p, &any_noncanonical_p); if (any_structural_p) SET_TYPE_STRUCTURAL_EQUALITY (t); else if (any_noncanonical_p) TYPE_CANONICAL (t) =3D build_function_type (TYPE_CANONICAL (value_type), canon_argtypes); if (!COMPLETE_TYPE_P (t)) layout_type (t); return t; }=