Bug 54785 - g++ error: class A is inaccessible
Summary: g++ error: class A is inaccessible
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-10-18 21:38 UTC by olchansk
Modified: 2007-04-18 16:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-10-18 21:38:31 UTC
Embargoed:


Attachments (Terms of Use)

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).


Note You need to log in before you can comment on or make changes to this bug.