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

--- Comment #2 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:cc79849cc883146964f0001f33c8b7eb576825c4

commit r16-4028-gcc79849cc883146964f0001f33c8b7eb576825c4
Author: Nathaniel Shead <nathanielosh...@gmail.com>
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 <nathanielosh...@gmail.com>
    Reviewed-by: Patrick Palka <ppa...@redhat.com>

Reply via email to