I have a problem which I narrowed down to the following code:
class A
{
};
class B : private A
{
};
void f(A*)
{
}
void f(void*)
{
}
int main()
{
B b;
f(&b);
}
Which gives the following error with gcc 4.7:
error: ‘A’ is an inaccessible base of ‘B’
I know that A is inaccessible but I would have liked the compiler to call f(void*). Is this behavior normal or am I doing something wrong? Or maybe it's a compiler bug?
Overloading is resolved before access checking. So the compiler chooses f(A*) as the appropriate overload, then determines that &b can't be converted to A* and gives the error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With