From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CF5593857712; Thu, 7 Mar 2024 21:39:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF5593857712 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709847579; bh=VXnh3Gn2YVAT9wLNHt3+rhArODPi4w/G8/MYGQL7UB4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xpx8mTMQ96Jr5InKA1sGXLBGX6x3ACUl6quW5gOdIUYT3mUOHlpwHCnJeLjeH3HQM lJsxM7cTtqateWEthe2zrNVi8SI59FgzDCbGBzJEWaUwQwayyn67yTLFe1W54Jhrfb j8DtxpyMT7FCmOHf9JHLkcOQKgZN4LPgZwcaECvE= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment Date: Thu, 07 Mar 2024 21:39:38 +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: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka 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=3D103994 --- Comment #5 from GCC Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:f5c1224708a0cf9cc2770c44bbbe7d0c883942be commit r14-9374-gf5c1224708a0cf9cc2770c44bbbe7d0c883942be Author: Patrick Palka Date: Thu Mar 7 16:39:20 2024 -0500 c++/modules: member alias tmpl partial inst [PR103994] Alias templates are weird in that their specializations can appear in both decl_specializations and type_specializations. They're always in the decl table, and additionally appear in the type table only at parse time via finish_template_type. There seems to be no good reason for them to appear in both tables, and the code paths end up stepping over each other in particular for a partial instantiation such as A::key_arg in the below modules testcase: the type code path (lookup_template_class) wants to set TI_TEMPLATE to the most general template whereas the decl code path (tsubst_template_decl called during instantiation of A) already set TI_TEMPLATE to the partially instantiated TEMPLATE_DECL. This TI_TEMPLATE change ends up confusing modules which decides to stream the logically equivalent TYPE_DECL and TEMPLATE_DECL for this partial instantiation separately. This patch fixes this by making lookup_template_class dispatch to instantiate_alias_template early for alias template specializations. In turn we now add such specializations only to the decl table. This admits some nice simplification in the modules code which otherwise has to cope with such specializations appearing in both tables. PR c++/103994 gcc/cp/ChangeLog: * cp-tree.h (add_mergeable_specialization): Remove second parameter. * module.cc (depset::disc_bits::DB_ALIAS_TMPL_INST_BIT): Remove. (depset::disc_bits::DB_ALIAS_SPEC_BIT): Remove. (depset::is_alias_tmpl_inst): Remove. (depset::is_alias): Remove. (merge_kind::MK_tmpl_alias_mask): Remove. (merge_kind::MK_alias_spec): Remove. (merge_kind_name): Remove entries for alias specializations. (trees_out::core_vals) : Adjust after removing is_alias_tmpl_inst. (trees_in::decl_value): Adjust add_mergeable_specialization calls. (trees_out::get_merge_kind) : Use MK_decl_spec for alias template specializations. (trees_out::key_mergeable): Simplify after MK_tmpl_alias_mask removal. (depset::hash::make_dependency): Adjust after removing DB_ALIAS_TMPL_INST_BIT. (specialization_add): Don't allow alias templates when !decl_p. (depset::hash::add_specializations): Remove now-dead code accomodating alias template specializations in the type table. * pt.cc (lookup_template_class): Dispatch early to instantiate_alias_template for alias templates. Simplify accordingly. (add_mergeable_specialization): Remove alias_p parameter and simplify accordingly. gcc/testsuite/ChangeLog: * g++.dg/modules/pr99425-1_b.H: s/alias/decl in dump scan. * g++.dg/modules/tpl-alias-1_a.H: Likewise. * g++.dg/modules/tpl-alias-2_a.H: New test. * g++.dg/modules/tpl-alias-2_b.C: New test. Reviewed-by: Jason Merrill =