https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121500
Bug ID: 121500
Summary: lambda with deducing this argument by value produces
wrong result
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This C++23 program
```
#include <vector>
int main() {
auto l = [data = std::vector{0}](this auto) {
return data[0];
};
return l(); // expected 0, but GCC returns arbitrary value
}
```
shall return 0 as it does in Clang and MSVC. But in GCC the return value is not
zero, see https://gcc.godbolt.org/z/nrrsKTodK
This is a reduced example from https://stackoverflow.com/q/79730845/7325599