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

            Bug ID: 124144
           Summary: [reflection] missing access check for reflection-name
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

We should emit two errors here

```
class A {
protected:
    void fn ();
    int i;
};


class B : public A {
    void test() {
        constexpr auto r1 = ^^A::fn; // error
        constexpr auto r2 = ^^A::i;  // error
    }
};
```

just like we would for

  constexpr auto a1 = &A::fn;
  constexpr auto a2 = &A::i;


r.C: In member function ‘void B::test()’:
r.C:12:33: error: ‘void A::fn()’ is protected within this context
   12 |         constexpr auto a1 = &A::fn; // error
      |                                 ^~
r.C:3:10: note: declared protected here
    3 |     void fn ();
      |          ^~
r.C:13:33: error: ‘int A::i’ is protected within this context
   13 |         constexpr auto a2 = &A::i;  // error
      |                                 ^
r.C:4:9: note: declared protected here
    4 |     int i;
      |         ^

Reply via email to