1 // PR rtl-optimization/23299 2 // { dg-do run } 3 // { dg-options "-Os" } 4 5 extern "C" void abort (); 6 7 struct A 8 { 9 virtual int a () { return 0; } 10 }; 11 12 struct B : public A 13 { 14 virtual int b () { return 0; } 15 }; 16 17 struct C : public A 18 { 19 virtual int c () { return 0; } 20 }; 21 22 struct D 23 { 24 D () { d = 64; } 25 ~D (); 26 int d; 27 }; 28 29 int x; 30 31 D::~D () 32 { 33 x |= 1; 34 if (d != 64) 35 abort (); 36 } 37 38 struct E : public B, public C 39 { 40 E () {} 41 virtual int c (); 42 ~E (); 43 D dv; 44 }; 45 46 E::~E () 47 { 48 int r = c (); 49 } 50 51 int E::c () 52 { 53 if (x > 10) 54 throw 1; 55 x |= 2; 56 return 0; 57 } 58 59 int main (void) 60 { 61 { 62 E e; 63 } 64 if (x != 3) 65 abort (); 66 } 67