This compiles and runs fine on Visual C++ 2015 Update 3 RC:
class A
{
template <class T> void f() {}
};
class B : A {};
class C : A {};
class D : B, C {};
int main()
{
D d;
d.f<int>();
}
There's two problems with this code:
f()
is private, sod.f<int>()
should fail to compile.f()
is ambiguous, as it could beB::f()
orC::f()
.
However, there's no diagnostic with /Wall
and B::f()
is called. Reversing the order D
inherits from gets C::f()
called, so I guess it's just using the first base class in the list.
Both g++ and clang get it right. Am I missing something or is this a bug in Visual C++?