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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Nathaniel Shead
<nsh...@gcc.gnu.org>:

https://gcc.gnu.org/g:2d1244a5b2dca62b97656cdfa28cd99af583aaa8

commit r15-9714-g2d1244a5b2dca62b97656cdfa28cd99af583aaa8
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Sat May 17 23:51:07 2025 +1000

    c++/modules: Fix ICE on merge of instantiation with partial spec [PR120013]

    When we import a pending instantiation that matches an existing partial
    specialisation, we don't find the slot in the entity map because for
    partial specialisations we register the TEMPLATE_DECL but for normal
    implicit instantiations we instead register the inner TYPE_DECL.

    Because the DECL_MODULE_ENTITY_P flag is set we correctly realise that
    it is in the entity map, but ICE when attempting to use that slot in
    partition handling.

    This patch fixes the issue by detecting this case and instead looking
    for the slot for the TEMPLATE_DECL.  It doesn't matter that we never add
    a slot for the inner decl because we're about to discard it anyway.

            PR c++/120013

    gcc/cp/ChangeLog:

            * module.cc (trees_in::install_entity): Handle re-registering
            the inner TYPE_DECL of a partial specialisation.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/partial-8.h: New test.
            * g++.dg/modules/partial-8_a.C: New test.
            * g++.dg/modules/partial-8_b.C: New test.
            * g++.dg/modules/partial-8_c.C: New test.
            * g++.dg/modules/partial-8_d.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
    Reviewed-by: Jason Merrill <ja...@redhat.com>
    (cherry picked from commit b0de7297f2b5670386472229ab795a577c288ecf)

Reply via email to