https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106552
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- expr.prim.lambda.capture/6 seems to imply this is invalid code. But the example is only with the parameter rather than a local variable ...