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

            Bug ID: 114257
           Summary: Error when 'this' is used in a lambda with an explicit
                    object parameter
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rl.alt.accnt at gmail dot com
  Target Milestone: ---

The following code (https://godbolt.org/z/3noEb3GG7)

struct S {
  int x;

  auto foo() {
    return [*this](this auto &self) {
      this->x = 4;
    };
  }
};

raises this error on trunk

<source>: In lambda function:
<source>:6:7: error: invalid use of 'this' in non-member function
    6 |       this->x = 4;
      |       ^~~~
  • [Bug c++/114257] New: Error whe... rl.alt.accnt at gmail dot com via Gcc-bugs

Reply via email to