Operator method lookup failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

Please consider the following example : 

> cat gcc_private_inheritance.cpp :

class A {};
class B : public A {};
class C : private B {
public:
 operator A& () {return *this;}
};

void doSomething (const A&) {}

int main (int argc, char** argv){
 C instC;
 // Attempt 1. Causes compiler error, not expected
 doSomething (instC.operator A&());
 // Attempt 2. Causes compiler error, standard-conforming behaviour
 doSomething (instC);
 // Attempt 3. Fine!
 doSomething (instC.C::operator A&());
 return 0;
}

> g++ gcc_private_inheritance.cpp -Wall -save-temps :
gcc_private_inheritance.cpp: In function ‘int main(int, char**)’:
gcc_private_inheritance.cpp:1: error: ‘class A’ is inaccessible
gcc_private_inheritance.cpp:13: error: within this context
gcc_private_inheritance.cpp:15: error: ‘A’ is an inaccessible base of ‘C

I don`t see why (1) attempt to call 'C::operator A&' method should fail while
(3) attempt succeeds.

I`ve created a bug report (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43189),
but It seems that it has been lost in time :)


Thank you

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux