Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C

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