[Bug c++/117518] templated generic (auto argument) lambda as default template argument is rejected and causing an ICE

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 23 08:30:34 GMT 2025


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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:4d02f20772f170b78491769a78086c92de127f95

commit r16-6352-g4d02f20772f170b78491769a78086c92de127f95
Author: Egas Ribeiro <egas.g.ribeiro@gmail.com>
Date:   Fri Dec 19 16:58:58 2025 +0000

    c++: Fix ICE with lambdas combining explicit and implicit template params
[PR117518]

    When a lambda with explicit template parameters like []<int> also has
    implicit template parameters from auto, and is used as a default
    template argument, processing_template_parmlist remained set
    from the outer template context. This caused
    function_being_declared_is_template_p to incorrectly return false,
    leading synthesize_implicit_template_parm to create a new template
    scope instead of extending the existing one, resulting in a binding
    level mismatch and an ICE in poplevel_class.

    Fix by clearing processing_template_parmlist in
    cp_parser_lambda_expression alongside the other parser state
    save/restore operations.

            PR c++/117518

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_lambda_expression): Clear
            processing_template_parmlist when parsing lambda body.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/lambda-targ19.C: New test.

    Signed-off-by: Egas Ribeiro <egas.g.ribeiro@gmail.com>
    Reviewed-by: Jason Merrill <jason@redhat.com>


More information about the Gcc-bugs mailing list