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