| 1 | #include <setjmp.h> |
|---|---|
| 2 | #include <stdio.h> |
| 3 | #include <time.h> |
| 4 | |
| 5 | jmp_buf j; |
| 6 | |
| 7 | void do_jump(void) |
| 8 | { |
| 9 | // We can't let the compiler know this will always happen or it might make |
| 10 | // optimizations that break our test. |
| 11 | if (!clock()) |
| 12 | longjmp(env: j, val: 1); // non-local goto |
| 13 | } |
| 14 | |
| 15 | int main (void) |
| 16 | { |
| 17 | if (setjmp(j) == 0) |
| 18 | do_jump(); |
| 19 | else |
| 20 | return 0; // destination of longjmp |
| 21 | |
| 22 | return 1; |
| 23 | } |
| 24 |
