public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-103994-4-Z30odmcfxD@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103994-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103994

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:f5c1224708a0cf9cc2770c44bbbe7d0c883942be

commit r14-9374-gf5c1224708a0cf9cc2770c44bbbe7d0c883942be
Author: Patrick Palka <ppalka@redhat.com>
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<B>::key_arg<T> 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<B>) 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) <case TEMPLATE_DECL>: Adjust after
            removing is_alias_tmpl_inst.
            (trees_in::decl_value): Adjust add_mergeable_specialization
            calls.
            (trees_out::get_merge_kind) <case depset::EK_SPECIALIZATION>:
            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 <jason@redhat.com>

  parent reply	other threads:[~2024-03-07 21:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 16:56 [Bug c++/103994] New: Module ICE in mark_by_value, at cp/module.cc:4772 unlvsur at live dot com
2022-10-18 12:59 ` [Bug c++/103994] Module ICE in write_var_def with global variable in global module fragment ppalka at gcc dot gnu.org
2023-02-01 17:33 ` Melven.Roehrig-Zoellner at DLR dot de
2024-01-27 16:10 ` ppalka at gcc dot gnu.org
2024-01-27 16:15 ` ppalka at gcc dot gnu.org
2024-03-04 16:02 ` ppalka at gcc dot gnu.org
2024-03-07 21:39 ` cvs-commit at gcc dot gnu.org [this message]
2024-03-07 21:40 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103994-4-Z30odmcfxD@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).