Bug 112455 - befriending a lambda closure type doesn't grant access to the lambda body
Summary: befriending a lambda closure type doesn't grant access to the lambda body
Status: RESOLVED DUPLICATE of bug 102791
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-09 08:39 UTC by Richard Smith
Modified: 2023-11-09 12:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2023-11-09 08:39:20 UTC
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.
Comment 1 Andrew Pinski 2023-11-09 12:48:59 UTC
Dup of bug 102791.

*** This bug has been marked as a duplicate of bug 102791 ***