2 // Shows that problem of initializing one object's secondary base from
3 // another object via a user defined copy constructor for that base,
4 // the pointer for the secondary vtable is not set after implicit
5 // copying of the outer class, but rather has the pointer to the main
6 // vtable for the secondary base left over from the user defined copy
7 // constructor for that base.
9 // Correct answer is B::beefy.
10 // g++ prints A::beefy, which is wrong. Cfront gets it right.
14 extern "C" int printf(const char *, ...);
15 extern "C" void exit(int);
25 virtual void print(void) const { }
26 B compute(void) const;
32 C(C& o) { } // with it, things are wrong, without it, they're ok
33 virtual void beefy(void) const { printf("A::beefy\n"); exit(1); }
36 class B : private A, public C {
39 void beefy(void) const { printf("B::beefy\n"); }
42 B A::compute(void) const
45 return static_cast<B&>(sub);
51 titi.compute().beefy();