Different compiler seems to have different opinion on the subject. The following code compiles fine with gcc
, but fails with clang
:
class Base {
protected:
static void f() {}
};
class Derived : public Base {
friend class DerivedFriend;
};
class DerivedFriend {
public:
void g() {
Base::f();
}
};
clang
's error is:
main.cpp:13:15: error: 'f' is a protected member of 'Base'
Base::f();
^
main.cpp:3:17: note: declared protected here
static void f() {}
^
1 error generated.