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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Nathaniel Shead
<[email protected]>:

https://gcc.gnu.org/g:217066a4635c951afccf54de9d98432750371353

commit r15-10348-g217066a4635c951afccf54de9d98432750371353
Author: Nathaniel Shead <[email protected]>
Date:   Tue Sep 23 00:18:43 2025 +1000

    c++: Fix canonical type for lambda pack captures [PR122015]

    comp_template_parms_position uses whether a TEMPLATE_TYPE_PARM is a pack
    to determine equivalency.  This in turn affects whether
    canonical_type_parameter finds a pre-existing auto type as equivalent.

    When generating the 'auto...' type for a lambda pack capture, we only
    mark it as a pack after generating the node (and calculating its
    canonical); this means that later when comparing a version streamed in
    from a module we think that two equivalent types have different
    TYPE_CANONICAL, because the latter already had
    TEMPLATE_PARM_PARAMETER_PACK set before calculating its canonical.

    This patch fixes this by using a new 'make_auto_pack' function to ensure
    that packness is set before the canonical is looked up.

            PR c++/122015

    gcc/cp/ChangeLog:

            * cp-tree.h (make_auto_pack): Declare.
            * lambda.cc (lambda_capture_field_type): Use make_auto_pack to
            ensure TYPE_CANONICAL is set correctly.
            * pt.cc (make_auto_pack): New function.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/lambda-11.h: New test.
            * g++.dg/modules/lambda-11_a.H: New test.
            * g++.dg/modules/lambda-11_b.C: New test.

    Signed-off-by: Nathaniel Shead <[email protected]>
    Reviewed-by: Patrick Palka <[email protected]>
    (cherry picked from commit cc79849cc883146964f0001f33c8b7eb576825c4)

Reply via email to