Bug 54785

Summary: g++ error: class A is inaccessible
Product: [Retired] Red Hat Linux Reporter: olchansk
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-10-18 21:38:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description olchansk 2001-10-18 21:38:27 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5) Gecko/20011012

Description of problem:
The attached C++ program does not compile with g++ 2.96-99
with a bogus "`class A' is inaccessible" error. egcs-1.1.2
and gcc-2.95.3 are okey. This problem is present in
OpenSP (from OpenJade: openjade.sourceforge.net).


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
Do this:

[olchansk@sam g++-opensp]$ cat test.cc
#include <stdio.h>

class A
{
public:
  int aaa;
};

class B: private A
{
public:
  int bbb;
};

class C: public B
{
public:
  A   ccc;
};
[olchansk@sam g++-opensp]$ g++ -c test.cc
test.cc:4: `class A' is inaccessible
test.cc:18: within this context
[olchansk@sam g++-opensp]$ g++ -v        
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-99)
[olchansk@sam g++-opensp]$ 


Expected Results:  The fact that class A is present somewhere in the
inheritance
tree should not affect normal use of class A (i.e. as a class member).

These compilers produce expected results (no compilation error):
egcs-1.1.2 (redhat-6.2), gcc-2.95.3 and
SGI CC (MIPSpro Compilers: Version 7.3.1.1m).
These compilers produce an error:
- gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-99)
- gcc version 3.0.2 20010905 (Red Hat Linux 7.1 3.0.1-3)


Additional info:

If this is actually a bug (and not a language feature),
and if it is present in gcc-3.1, please file a GCC PR-
I am not familiar enough with the GCC PR system...

Comment 1 Jakub Jelinek 2001-10-18 21:45:47 UTC
g++ 3.0 and 3.1 behave the same, and no, this is not a compiler bug.
The inheritance brings A into class C scope as private.
If you want to access A in C, you should use ::A instead
(provided it is in the global namespace, otherwise the_namespace::A).