1 // { dg-do run } 2 // Bug: obj gets destroyed twice because the fixups for the return are 3 // inside its cleanup region. 4 5 extern "C" int printf (const char *, ...); 6 7 int d; 8 9 struct myExc { }; 10 11 struct myExcRaiser { 12 ~myExcRaiser() { throw myExc(); } 13 }; 14 15 struct stackObj { 16 ~stackObj() { ++d; printf ("stackObj::~stackObj()\n"); } 17 }; 18 19 int test() 20 { 21 myExcRaiser rais; 22 stackObj obj; 23 return 0; 24 } 25 26 int main() 27 { 28 try { 29 test(); 30 } 31 catch (myExc &) { 32 return d != 1; 33 } 34 return 1; 35 } 36