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

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

https://gcc.gnu.org/g:87ffd205fe0f4cbabd3d22cba815b02c0466d9ed

commit r15-6890-g87ffd205fe0f4cbabd3d22cba815b02c0466d9ed
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Sun Jan 12 04:00:56 2025 +1100

    c++/modules: Don't emit imported deduction guides [PR117397]

    The ICE in the linked PR is caused because name lookup finds duplicate
    copies of the deduction guides, causing a checking assert to fail.

    This is ultimately because we're exporting an imported guide; when name
    lookup processes 'dguide-5_b.H' it goes via the 'tt_entity' path and
    just returns the entity from 'dguide-5_a.H'.  Because this doesn't ever
    go through 'key_mergeable' we never set 'BINDING_VECTOR_GLOBAL_DUPS_P'
    and so deduping is not engaged, allowing duplicate results.

    Currently I believe this to be a perculiarity of the ANY_REACHABLE
    handling for deduction guides; in no other case that I can find do we
    emit bindings purely to imported entities.  As such, this patch fixes
    this problem from that end, by ensuring that we simply do not emit any
    imported deduction guides.  This avoids the ICE because no duplicates
    need deduping to start with, and should otherwise have no functional
    change because lookup of deduction guides will look at all reachable
    modules (exported or not) regardless.

    Since we're now deliberately not emitting imported deduction guides we
    can use LOOK_want::NORMAL instead of LOOK_want::ANY_REACHABLE, since the
    extra work to find as-yet undiscovered deduction guides in transitive
    importers is not necessary here.

            PR c++/117397

    gcc/cp/ChangeLog:

            * module.cc (depset::hash::add_deduction_guides): Don't emit
            imported deduction guides.
            (depset::hash::finalize_dependencies): Add check for any
            bindings referring to imported entities.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/dguide-5_a.H: New test.
            * g++.dg/modules/dguide-5_b.H: New test.
            * g++.dg/modules/dguide-5_c.H: New test.
            * g++.dg/modules/dguide-6.h: New test.
            * g++.dg/modules/dguide-6_a.C: New test.
            * g++.dg/modules/dguide-6_b.C: New test.
            * g++.dg/modules/dguide-6_c.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to