<div dir="ltr">Thanks for looking this over. I'd be happy to work on a fix.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 1, 2019 at 1:32 PM Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Mon, 1 Jul 2019 at 10:10, Logan Smith via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Salutations all -- brand-new, aspiring Clang hacker here. <div><br></div><div>In spelunking through AST/DeclCXX.cpp to familiarize myself with things, I stumbled upon the implementation of CXXRecordDecl::lambdaIsDefaultConstructibleAndAssignable(). It -- very conveniently -- cites the C++2a draft as per new rules involving lambda default construction and assignment:</div><div><br></div><div> C++2a [expr.prim.lambda.capture]p11:<br> The closure type associated with a lambda-expression has no default<br> constructor if the lambda-expression has a lambda-capture and a<br> defaulted default constructor otherwise. It has a deleted copy<br> assignment operator if the lambda-expression has a lambda-capture and<br> defaulted copy and move assignment operators otherwise.<br></div><div><br></div><div>By my reading, if a lambda has any captures whatsoever, its default constructor and copy assignment operators are deleted. However, the implementation in clang appears to only check for the presence of `capture-default`s:</div><div><br></div><div> if (getLambdaCaptureDefault() != LCD_None)<br> return false;<br> return getASTContext().getLangOpts().CPlusPlus2a;<br></div><div><br></div><div>In fact, the commit where this feature was introduced (864949bda1db) very explicitly only provides for lambdas with `capture-default's. This leads the following code to be (erroneously, by my reading) accepted by clang with -std=c++2a:</div><div><br></div><div> void f(int i) {<br> auto lam1 = [i] {};<br> decltype(lam1) lam2;<br> }<br></div><div><br></div><div>while the following is (correctly) rejected:</div><div><br></div><div> void f(int i) {<br> auto lam1 = [=] {};<br> decltype(lam1) lam2;<br> }<br></div><div><br></div><div>My question is: is the current implementation 1) intentional, and 2) correct?</div></div></blockquote><div><br></div><div>The current implementation is unintentionally wrong. Thanks for catching this! Are you interested in providing a fix?</div></div></div>
</blockquote></div>