Example code:

class A {
};

class B : A {
};

class C : B {
public:
        int c(A *a) { return 7; }
};

int main() { 
        
        A a;
        C c;

        return c.c( &a );
}

Gives the error message:

g++ main.cc
        main.cpp:1: `class A' is inaccessible
        main.cpp:9: within this context

Which is true, but not relevant. C never tries to access A through B.

-- 
           Summary: g++ rejects valid code with 'is inaccessible' error
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: matthew dot whitney at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20397

Reply via email to