[Bug c++/22540] New: No access to public static members/functions of privately inherited base class
mdweb at web dot de
gcc-bugzilla@gcc.gnu.org
Sun Jul 17 23:50:00 GMT 2005
$uname -srm
Linux 2.6.11.4-21.7-default i686
$tmp/bin/g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++
--prefix=/home/xxx/tmp : (reconfigured) ../gcc/configure
--enable-languages=c,c++ --prefix=/home/xxx/tmp :
(reconfigured) ../gcc/configure --enable-languages=c,c++ --prefix=/home/xxx/tmp
Thread model: posix
gcc version 4.1.0 20050717 (experimental)
The following code is rejected:
class A
{
public:
static void foo() {}
static int i;
};
class B : private A
{
};
class C : public B
{
public:
void foo2()
{
A::foo(); // line 18
int c=A::i; // line 20
}
};
Compilation with g++ -c test.cpp yields
test.cpp: In member function ‘void C::foo2()’:
test.cpp:3: error: ‘class A’ is inaccessible
test.cpp:18: error: within this context
test.cpp:3: error: ‘class A’ is inaccessible
test.cpp:20: error: within this context
Making C inherit directly from A works, though (i.e., Class C : private A).
Also, g++ 3.3.4 and 3.3.5 did accept the code above.
Thanks,
Michael
--
Summary: No access to public static members/functions of
privately inherited base class
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mdweb at web dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22540
More information about the Gcc-bugs
mailing list