http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53696
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-07 15:54:22 UTC --- And struct A; template <int N> void foo(A& a) { [=](){a;}; } void bar (A&a) { foo<6>(a); } ICEs even without -fkeep-inline-functions elsewhere. I wonder if else /* Capture by copy requires a complete type. */ type = complete_type (type); in semantics.c (add_capture) shouldn't be something like: --- cp/semantics.c.jj 2012-12-06 21:33:57.000000000 +0100 +++ cp/semantics.c 2012-12-07 16:45:30.000000000 +0100 @@ -9164,7 +9164,14 @@ add_capture (tree lambda, tree id, tree } else /* Capture by copy requires a complete type. */ - type = complete_type (type); + { + if (processing_template_decl) + type = complete_type (type); + else + type = complete_type_or_else (type, initializer); + if (type == NULL_TREE) + type = error_mark_node; + } /* Add __ to the beginning of the field name so that user code won't find the field with name lookup. We can't just leave the name This fixes the ICE in #c0 (but we error twice for the incomplete type, once within the lambda, once within the parent function). For templates it of course doesn't change anything, we I think generally can't require the type to be complete there, so it must be done later during pt.c.