From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BBFB3384AB47; Fri, 3 May 2024 07:25:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBFB3384AB47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714721157; bh=JIGSFp80o4k6Mxe4JirXKMxeIdBQE0cRPITer2FTo3U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cKCalBvX8VUX9qmdSmHN7i0CWdAbjaL3CClYmSfcZlauQ/6y8RCYzOslQjwEZrizA Q+N/AzDt0oBXzbmCxCecR5Q1Qlok60jmv6nqf6R5c9gsx+IEhD/YLjusKpslhJhDN3 1bUna2aTJC9+b22+7TszpfIZhu0r+pYEfyspPtx8= 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:25:57 +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: 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 --- Comment #8 from Richard Biener --- So a real fix might look like the following (requiring changes in all other type builders to first set/compute the canonical type of course). diff --git a/gcc/tree.cc b/gcc/tree.cc index 83f3bf306af..5dfe12f0e96 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -6012,6 +6012,9 @@ type_hash_canon_hash (tree type) hstate.add_int (TREE_CODE (type)); + if (TYPE_CANONICAL (type)) + hstate.add_object (TYPE_HASH (TYPE_CANONICAL (type))); + if (TREE_TYPE (type)) hstate.add_object (TYPE_HASH (TREE_TYPE (type))); @@ -6109,6 +6112,9 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) || TYPE_MODE (a->type) !=3D TYPE_MODE (b->type))) return false; + if (TYPE_CANONICAL (a->type) !=3D TYPE_CANONICAL (b->type)) + return false; + switch (TREE_CODE (a->type)) { case VOID_TYPE: @@ -7507,10 +7513,6 @@ build_function_type (tree value_type, tree arg_types, 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; @@ -7523,6 +7525,16 @@ build_function_type (tree value_type, tree arg_types, TYPE_CANONICAL (t) =3D build_function_type (TYPE_CANONICAL (value_type= ), canon_argtypes); + /* 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); + if (!COMPLETE_TYPE_P (t)) layout_type (t); return t;=