g++ fails to overlook template instantiation errors involving down static_casts
over virtual inheritance boundaries. Example:
struct B {};
struct D : B {};
struct VD : virtual B {};
template <class T> T create();
typedef char one[1];
typedef char two[2];
template <class D, class B>
one& f(char (*)[sizeof(static_cast<D>(create<B>()))]);
template <class D, class B>
two& f(...);
int main()
{
f<D*, int>(0);
f<D*, B*>(0);
f<VD*, B*>(0);
return 0;
}
gives error: cannot convert from base B to derived type VD via virtual base
B
Expected behavior is for template instantiation to fail for the first template
f function and selection of the second template f function.
Same issue for gcc 4.3.4.
May be related to report 41468.
--
Summary: SFINAE does not handle down static_cast over virtual
inheritance
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cjoldfield at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44267