1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for
3 // full license information.
4 
5 #include <windows.h>
6 #include <setjmp.h>
7 #include "seh.h"
8 
9 char test[] = "SEH0023.c";
10 int perfect;
11 
12 int main() {
13   jmp_buf JumpBuffer;
14   LONG Counter;
15 
16   Counter = 0;
17 
18   if (_setjmp(JumpBuffer) == 0) {
19     try {
20       try {
21         /* set counter = 1 */
22         *(volatile LONG*)&Counter += 1;
23         RaiseException(EXCEPTION_INT_OVERFLOW, 0, /*no flags*/ 0, 0);
24       }
25       finally {
26         /* set counter = 2 */
27         *(volatile LONG*)&Counter += 1;
28         longjmp(JumpBuffer, 1);
29       }
30       endtry
31     }
32     except(1)
33     /* should never get here */
34     {
35       *(volatile LONG*)&Counter += 1;
36     }
37     endtry
38   } else {
39     /* set counter = 3 */
40     *(volatile LONG*)&Counter += 1;
41   }
42 
43   if (Counter != 3) {
44     printf("TEST 23 FAILED. Counter = %d\n\r", Counter);
45     return -1;
46   }
47 
48   return 0;
49 }
50