1 // Author: Alfred Miniarik <a8601248@unet.univie.ac.at>
2 // test of dynamic_cast
3 // runtime detecting of nonpublic
4 // inheritance within a cast
5 // and therefor failing with result 0.
7 extern "C" void abort();
8 extern "C" int printf (const char *, ...);
10 static int errors = 0;
14 printf("Error %i\n",i);
18 struct A {virtual ~A(){}};
19 struct B : private virtual A {};
20 struct C : virtual A {};
28 if(&d != dynamic_cast<D*>(ap)) error(1);
29 if((B*)&d != dynamic_cast<B*>(ap)) error(2);
30 if((C*)&d != dynamic_cast<C*>(ap)) error(3);
31 return errors ? 1 : 0;