https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115722
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- You missed this part: The closure type is declared in the smallest block scope, class scope, or namespace scope that contains the corresponding lambda-expression. from expr.prim.lambda.closure/2 Which means the closure type is in the global scope here for this TU.