Debian Codegraph @

gcc/testsuite/g++.dg/eh/filter2.C

raw
1 // Test that terminate gets run when a catch filter fails to match while
2 // running destructors. Original bug depended on a::~a being inlined.
3 // { dg-do run }
4 // { dg-options -O }
5 // { dg-skip-if "requires hosted libstdc++ for cstdlib abort" { ! hostedlib } }
6
7 #include <exception>
8 #include <cstdlib>
9
10 struct e1 {};
11 struct e2 {};
12
13 struct a
14 {
15 a () { }
16
17 ~a ()
18 {
19 try
20 {
21 throw e1();
22 }
23 catch (e2 &)
24 {
25 }
26 }
27 };
28
29 void
30 ex_test ()
31 {
32 a aa;
33 try
34 {
35 throw e1 ();
36 }
37 catch (e2 &)
38 {
39 }
40 }
41
42 void my_terminate ()
43 {
44 std::exit (0);
45 }
46
47 int
48 main ()
49 {
50 std::set_terminate (my_terminate);
51
52 try
53 {
54 ex_test ();
55 }
56 catch (...)
57 {
58 }
59 abort ();
60 }