https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119038
Bug ID: 119038
Summary: Internal compiler error calling method with explicit
this parameter from generic lambda with implicitly
captured this
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rmccampbell7 at gmail dot com
Target Milestone: ---
Created attachment 60597
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60597&action=edit
GCC crash report from -freport-bug
Version/system: g++-14 (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0
Minimal reproducing example, compiled with `g++-14 -std=c++23 temp.cpp -o
temp`:
```
class Foo {
public:
Foo() {
[&]<typename T>(T x) {
bar<T>();
}(1);
}
template <typename T>
void bar(this Foo& self) {}
};
int main() {
Foo foo;
}
```
G++ crashes with "internal compiler error: trying to capture ‘this’ in
instantiation of generic lambda". The full crash report from -freport-bug is
attached.
It seems that any of: making the `this` capture explicit (i.e. `[this]{...}`),
qualifying bar as `this->bar<T>()`, moving the template parameter T out of the
lambda (i.e. to Foo or Foo()), removing the dependence on T from bar (i.e.
fixing it to `bar<int>`), or removing the explicit `this` parameter, all
prevent the crash.