Files
gcc-reflection/gcc/testsuite/g++.dg/cpp1y/lambda-generic-this6.C
Jason Merrill 90ad957406 c++: implicit 'this' in generic lambda [PR122048]
Here template substitution was replacing a reference to the 'this' of X::f
with the implicit closure parameter of the operator(), which is wrong.  The
closure parameter is never a suitable replacement for a 'this' parameter.

	PR c++/122048

gcc/cp/ChangeLog:

	* pt.cc (tsubst_expr): Don't use a lambda current_class_ptr.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/lambda-generic-this6.C: New test.
2025-09-27 09:04:58 +01:00

9 lines
130 B
C

// PR c++/122048
// { dg-do compile { target c++14 } }
class X {
void f();
int i;
};
void X::f() {[&](auto) {sizeof i;}(1);}