[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 08:51:03 PDT 2017


ahatanak added a comment.

In https://reviews.llvm.org/D36915#849622, @faisalv wrote:

> I don't think this approach is entirely correct for at least the following reasons:
>
> 1. in the lambda case the machinery that diagnoses capture failures should be the machinery erroring on the lambda (when the parameter is odr-used)
> 2. in the unevaluated case, once you disable the error, the instantiation machinery will fail to find the corresponding instantiated parmvardecl.


Oh right, it stills assert in the unevaluated case. I should have a test case for that too.

I also found that the following code, which has a lambda that doesn't capture anything, asserts (in IRGen):

  struct S {
    template<class T>
    S(T&&) {}
  };
  
  template<class T>
  void foo1() {
    struct S2 {
      void foo2(S s = [](){}) {
      }
    };
  
    S2 s2;
    s2.foo2();
  }
  
  void foo3() {
    foo1<int>();
  }


https://reviews.llvm.org/D36915





More information about the cfe-commits mailing list