1103793Stjr// { dg-do run } 2103793Stjr// Shows that problem of initializing one object's secondary base from 3103793Stjr// another object via a user defined copy constructor for that base, 4103793Stjr// the pointer for the secondary vtable is not set after implicit 5103793Stjr// copying of the outer class, but rather has the pointer to the main 6103793Stjr// vtable for the secondary base left over from the user defined copy 7103793Stjr// constructor for that base. 8103793Stjr 9103793Stjr// Correct answer is B::beefy. 10103793Stjr// g++ prints A::beefy, which is wrong. Cfront gets it right. 11103793Stjr 12103793Stjr// prms-id: 2846 13103793Stjr 14103793Stjrextern "C" int printf(const char *, ...); 15103793Stjrextern "C" void exit(int); 16103793Stjr 17103793Stjrclass B; 18103793Stjr 19103793Stjrclass A { 20103793Stjr public: 21103793Stjr 22103793Stjr A(void){} 23103793Stjr A(const A&){} 24103793Stjr 25103793Stjr virtual void print(void) const { } 26103793Stjr B compute(void) const; 27103793Stjr}; 28103793Stjr 29103793Stjrclass C { 30103793Stjrpublic: 31103793Stjr C() { } 32103793Stjr C(C& o) { } // with it, things are wrong, without it, they're ok 33103793Stjr virtual void beefy(void) const { printf("A::beefy\n"); exit(1); } 34103793Stjr}; 35103793Stjr 36103793Stjrclass B : private A, public C { 37103793Stjrpublic: 38103793Stjr B(const A& x, int){} 39103793Stjr void beefy(void) const { printf("B::beefy\n"); } 40103793Stjr}; 41103793Stjr 42103793StjrB A::compute(void) const 43103793Stjr{ 44103793Stjr B sub(*this, 1); 45103793Stjr return sub; 46103793Stjr} 47103793Stjr 48103793Stjrint main () 49103793Stjr{ 50103793Stjr A titi; 51103793Stjr titi.compute().beefy(); 52103793Stjr return 0; 53103793Stjr} 54103793Stjr