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&bcan’t be converted toA*and gives the error message.