https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112455
Bug ID: 112455
Summary: befriending a lambda closure type doesn't grant access
to the lambda body
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: richard-gccbugzilla at metafoo dot co.uk
Target Milestone: ---
Testcase:
class C;
auto x = []<typename MyC = C>(MyC *p) {
return p->n;
};
class C {
int n;
friend decltype(x);
} c;
int k = x(&c);
This appears to be valid, and Clang, MSVC, and EDG accept, but GCC reports an
access error. The templated operator() of the lambda is a member function of a
friend of C, so should have access to C::n.