2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / eh / filter2.C
blobfe87cc9a30817efba61d3bb513d310e42df64e06
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 }
6 #include <exception>
7 #include <cstdlib>
9 struct e1 {};
10 struct e2 {};
12 struct a
14   a () { }
16   ~a ()
17     {
18       try
19         {
20           throw e1();
21         }
22       catch (e2 &)
23         {
24         }
25     }
28 void
29 ex_test ()
31   a aa;
32   try
33     {
34       throw e1 ();
35     }
36   catch (e2 &)
37     {
38     }
41 void my_terminate ()
43   std::exit (0);
46 int
47 main ()
49   std::set_terminate (my_terminate);
51   try
52     {
53       ex_test ();
54     }
55   catch (...)
56     {
57     }
58   abort ();