This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/78019] New: Local class with lambda in default member initializer cannot default-capture this


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78019

            Bug ID: 78019
           Summary: Local class with lambda in default member initializer
                    cannot default-capture this
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: columbo@gmx-topmail.de
  Target Milestone: ---

int main() {
    struct A {
        int x, i = [&] { return x; }();
    } a{0};
}

-----
> error: 'this' was not captured for this lambda function 

Making the default-capture `=' doesn't help, but explicitly capturing `this'
works.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]