[PATCH] Fix PR20619 - failure to define implicit copy ctor of a by val capture in a generic lambda

Faisal Vali faisalv at gmail.com
Fri Nov 7 09:54:15 PST 2014


Hi rsmith,

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 this less elegant solution seemed necessary.

Thoughts?

Thank you!

http://reviews.llvm.org/D6171

Files:
  include/clang/Sema/ScopeInfo.h
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/cxx1y-generic-lambdas-pr20619.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6171.15931.patch
Type: text/x-patch
Size: 7297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141107/26094b0e/attachment.bin>


More information about the cfe-commits mailing list