1*fe36f081STimo Kreuzer // Copyright (c) Microsoft. All rights reserved.
2*fe36f081STimo Kreuzer // Licensed under the MIT license. See LICENSE file in the project root for
3*fe36f081STimo Kreuzer // full license information.
4*fe36f081STimo Kreuzer 
5*fe36f081STimo Kreuzer #include <stdio.h>
6*fe36f081STimo Kreuzer int c, d;
7*fe36f081STimo Kreuzer struct A
8*fe36f081STimo Kreuzer {
9*fe36f081STimo Kreuzer     int i;
AA10*fe36f081STimo Kreuzer     A () { i = ++c; printf ("A() %d\n", i); }
AA11*fe36f081STimo Kreuzer     A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); }
~AA12*fe36f081STimo Kreuzer     ~A() { printf ("~A() %d\n", i); ++d; }
13*fe36f081STimo Kreuzer };
14*fe36f081STimo Kreuzer int
main()15*fe36f081STimo Kreuzer main ()
16*fe36f081STimo Kreuzer {
17*fe36f081STimo Kreuzer     try
18*fe36f081STimo Kreuzer     {
19*fe36f081STimo Kreuzer         try
20*fe36f081STimo Kreuzer         {
21*fe36f081STimo Kreuzer             printf ("Throwing 1...\n");
22*fe36f081STimo Kreuzer             throw A();
23*fe36f081STimo Kreuzer         }
24*fe36f081STimo Kreuzer         catch (A)
25*fe36f081STimo Kreuzer         {
26*fe36f081STimo Kreuzer             try
27*fe36f081STimo Kreuzer             {
28*fe36f081STimo Kreuzer                 printf ("Throwing 2...\n");
29*fe36f081STimo Kreuzer                 throw;
30*fe36f081STimo Kreuzer             }
31*fe36f081STimo Kreuzer             catch (A)
32*fe36f081STimo Kreuzer             {
33*fe36f081STimo Kreuzer                 printf ("Falling out...\n");
34*fe36f081STimo Kreuzer             }
35*fe36f081STimo Kreuzer         }
36*fe36f081STimo Kreuzer     }
37*fe36f081STimo Kreuzer     catch (A)
38*fe36f081STimo Kreuzer     {
39*fe36f081STimo Kreuzer         printf ("Caught.\n");
40*fe36f081STimo Kreuzer     }
41*fe36f081STimo Kreuzer     printf ("c == %d, d == %d\n", c, d);
42*fe36f081STimo Kreuzer     return c != d;
43*fe36f081STimo Kreuzer }
44