Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 54785 - g++ error: class A is inaccessible
g++ error: class A is inaccessible
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2001-10-18 17:38 EDT by olchansk
Modified: 2007-04-18 12:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-10-18 17:38:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description olchansk 2001-10-18 17:38:27 EDT
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:

Steps to Reproduce:
Do this:

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

class A
  int aaa;

class B: private A
  int bbb;

class C: public B
  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
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
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 17:45:47 EDT
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.