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

            Bug ID: 119240
           Summary: Lambda with an explicit object parameter disables
                    further captures of `this`
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nedimsehic50 at gmail dot com
  Target Milestone: ---

Output of gcc -std=c++23 main.cpp:

main.cpp: In lambda function:
main.cpp:3:32: error: invalid use of ‘this’ in non-member function
    3 |         [this](this auto&&) { [this] {}(); }();
      |                                ^~~~

Source:

struct S {
    S() {
        [this](this auto&&) { [this] {}(); }();
    }
};

This is very similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113563 but
I figure it's not the same bug since there `this` is used as an expression, but
here as a simple-capture.

Reply via email to