https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107741
--- Comment #5 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:12feb78be517472ca941953dce47d6e78e5a17f8 commit r15-7518-g12feb78be517472ca941953dce47d6e78e5a17f8 Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Fri Jan 31 21:19:45 2025 +1100 c++: Fix mangling of lambas in static member template initializers [PR107741] My fix for this issue in r15-7147 turns out to not be quite sufficient; static member templates apparently go down a different code path and need their own handling. PR c++/107741 gcc/cp/ChangeLog: * cp-tree.h (is_static_data_member_initialized_in_class): Declare new predicate. * decl2.cc (start_initialized_static_member): Push the TEMPLATE_DECL when appropriate. (is_static_data_member_initialized_in_class): New predicate. (finish_initialized_static_member): Use it. * lambda.cc (record_lambda_scope): Likewise. * parser.cc (cp_parser_init_declarator): Start the member decl early for static members so that lambda scope is set. (cp_parser_template_declaration_after_parameters): Don't register in-class initialized static members here. gcc/testsuite/ChangeLog: * g++.dg/abi/lambda-ctx2-19.C: Add tests for template members. * g++.dg/abi/lambda-ctx2-19vs20.C: Likewise. * g++.dg/abi/lambda-ctx2-20.C: Likewise. * g++.dg/abi/lambda-ctx2.h: Likewise. * g++.dg/cpp0x/static-member-init-1.C: Likewise. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com> Reviewed-by: Jason Merrill <ja...@redhat.com>