1 // { dg-do run  }
2 // Ensure that virtual base upcast and downcasting works on this
3 // conversions during virtual function dispatch at ctor/dtor time
4 // when dynamic vtable fixups for deltas are needed.
5 
6 int fail = 0;
7 
8 struct BASE1 {
~BASE1BASE19   virtual ~BASE1 () { }
10 };
11 
12 class MID;
13 
14 class BASE2 {
15 public:
VFN()16   virtual MID *VFN (){ return 0; }
17 };
18 
19 class MIBASE : public BASE1, public BASE2 { };
20 
21 class VBB : public MIBASE {
22 public:
23   virtual long get_STATE () const = 0;
print_STATE()24   void print_STATE() { if (get_STATE () != 87654321) fail = 1; }
25 };
26 
27 class VBD : public virtual VBB {
28   long STATE;
29 public:
get_STATE()30   long get_STATE() const { return STATE; }
VBD()31   VBD() { STATE = 87654321; }
~VBD()32   ~VBD() { STATE = 87654321; }
33 };
34 
35 class MID : public virtual VBD {
36 public:
MID()37   MID () { print_STATE(); }
~MID()38   ~MID () { print_STATE(); }
VFN()39   virtual MID *VFN() { return this; }
40 };
41 
42 class LAST : public MID {
43 public:
LAST()44   LAST () { print_STATE(); }
~LAST()45   ~LAST () { print_STATE(); }
46 };
47 
main()48 int main() {
49   MIBASE *o = new LAST;
50   MID *p = o->VFN();
51   p->print_STATE();
52   delete o;
53   return fail;
54 }
55