https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110584
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Simon Martin <simar...@gcc.gnu.org>: https://gcc.gnu.org/g:90e53ecdbfcc482ad3d0090658427de6d44a5d49 commit r15-8009-g90e53ecdbfcc482ad3d0090658427de6d44a5d49 Author: Simon Martin <si...@nasilyan.com> Date: Wed Mar 12 20:15:39 2025 +0100 c++: Look through capture proxy from outer lambda instead of erroring out [PR110584] We've been rejecting this valid code since r8-4571: === cut here === void foo (float); int main () { constexpr float x = 0; (void) [&] () { foo (x); (void) [] () { foo (x); }; }; } === cut here === The problem is that when processing X in the inner lambda, process_outer_var_ref errors out even though it does find the constant capture from the enclosing lambda. This patch makes sure that process_outer_var_ref properly looks through normal capture proxies, if any. PR c++/110584 gcc/cp/ChangeLog: * cp-tree.h (strip_normal_capture_proxy): Declare. * lambda.cc (strip_normal_capture_proxy): New function to look through normal capture proxies. (build_capture_proxy): Use it. * semantics.cc (process_outer_var_ref): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/lambda/lambda-nested10.C: New test.