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[] = "SEH0022.c"; 10 int perfect; 11 12 int main() { 13 jmp_buf JumpBuffer; 14 LONG Counter; 15 16 Counter = 0; 17 18 try { 19 if (_setjmp(JumpBuffer) == 0) { 20 /* set counter = 1 */ 21 //(volatile LONG) Counter += 1; 22 *(volatile LONG*)&Counter += 1; 23 } else { 24 /* set counter = 4 */ 25 //(volatile LONG) Counter += 1; 26 *(volatile LONG*)&Counter += 1; 27 } 28 } 29 finally { 30 /* set counter = 2 and 5 */ 31 Counter += 1; 32 if (Counter == 2) { 33 /* set counter = 3 */ 34 //(volatile LONG) Counter += 1; 35 *(volatile LONG*)&Counter += 1; 36 longjmp(JumpBuffer, 1); 37 } 38 } 39 endtry 40 41 if (Counter != 5) { 42 printf("TEST 22 FAILED. Counter = %d\n\r", Counter); 43 return -1; 44 } 45 46 return 0; 47 } 48