https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102791

            Bug ID: 102791
           Summary: Friend declaration of lambda function is ignored
           Product: gcc
           Version: 12.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 is a valid program:
```
constexpr auto f = [](auto& x){
    x.m();
};

class A{
    friend decltype(f);
    void m() {}
public:
    void n() {
        f(*this);
    }
};

int main(){
    A{}.n();
}
```
which is accepted by Clang and MSVC, but unfortunately not by GCC.

The error is
```
error: 'void A::m()' is private within this context
    2 |     x.m();
```
Demo: https://gcc.godbolt.org/z/vKnhqG9b1

Related discussion: https://stackoverflow.com/q/64390688/7325599

Reply via email to