c++/6372: private inheritance makes class totally inaccessible, even as parameter

david@mandrakesoft.com david@mandrakesoft.com
Fri Apr 19 08:16:00 GMT 2002


>Number:         6372
>Category:       c++
>Synopsis:       private inheritance makes class totally inaccessible, even as parameter
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 19 06:06:03 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     David Faure
>Release:        gcc-3.1 20020415 (prerelease) - same with "gcc-2.96"
>Organization:
>Environment:
Mandrake Linux 8.2 (also happens on SuSE), i686
>Description:
If B inherits privately from A, then a class inheriting from C cannot use A - not even as a parameter!

(see source code below)

g++ -c a.cc will error, saying:
/tmp/a.cc: In method `C::C (A *)':
/tmp/a.cc:1: `class A' is inaccessible
/tmp/a.cc:5: within this context

Works with gcc-2.95.x, and with SunCC.
>How-To-Repeat:
class A { };
class B : private A { };
class C : public B {
public:
    C(A*){}
};
>Fix:
There's no known fix, when the private inheritance cannot be changed into "public".
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list