http://llvm.org/bugs/show_bug.cgi?id=20619
Please see the above bug for details, but briefly:
Since a generic lambda's call operator is a dependent context, and since we have to process implicit captures once a generic lambda's call operator's DeclContext has been pushed (and currently process explicit by value captures that way too - (unlike init-captures whose initialization actually occurs prior to the call operator being pushed on)) - we need to indicate when deciding whether implicit special member functions should be generated, that we are initializing captures of generic lambdas and even though the current context is dependent, since the enclosing one is not, generate these implicit functions and mark them used.
For e.g.:
struct A { };
struct B : virtual A { };
int main() {
B x; [=](auto a) { x; }; // Sans patch, this will crash since the copy ctor of B will not get defined.
}
As discussed within the Bug Report, explicit captures by val could be fixed by moving their initialization to prior to the call operator's decl context being pushed on - but this would not address implicit by val captures - hence we now do the initialization analysis after the call-operator's context has been popped off (per Richard's suggestion!)
Thank you!