[31/77] Use scalar_int_mode for move2add
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p2846a.C
blob8825de4e8c32573ca23c418ea807a4da4b7ba092
1 // { dg-do run  }
2 // Shows that problem of initializing one object's vtable pointer from
3 // another object's vtable pointer when doing a default copy of it
4 // and the vtable pointer involved is the main one.
6 // Correct answer is B::print.
7 // g++ prints D::print, which is wrong.  Cfront gets is right.
9 // prms-id: 2846
11 extern "C" int printf(const char *, ...);
12 extern "C" void exit(int);
14 class B {
15 public:
16   virtual void print(void) const { printf("B::print\n"); }
19 class D : public B {
20 public:
21   void print(void) const { printf("D::print\n"); exit(1); }
22   B compute(void) const;
25 B D::compute(void) const
27   B sub(*(B*)this);
28   return sub;
31 int main () {
32   D titi;
33   titi.compute().print();
34   return 0;