Showing posts with label inheritance. Show all posts
Showing posts with label inheritance. Show all posts

Monday, July 23, 2012

Dear Lazyweb: Who is right g++ or clang?

#include <stdio.h>

class A
{
    protected:
        static void foo()
        {
            printf("HI\n");
        }
};

class B : public A
{
    friend class C;
};

class C
{
    public:
        void useFoo()
        {
            A::foo();
        }
};

int main(int argc, char **argv)
{
    C c;
    c.useFoo();
}

g++ compiles, clang complains that A::foo is protected and can't be used in C::useFoo.I know friendship is not inherited, but this is actually the reverse of inheriting, so does anyone has any pointer as to where i should open the bug? clang or gcc?