| 1 | (* A failed check ends the program with 2, which the procedures atExit |
| 2 | registered can see. *) |
| 3 | module StopStatus; |
| 4 | import Out, Rt; |
| 5 | |
| 6 | proc report; |
| 7 | begin |
| 8 | Out.str("ending with "); Out.int(Rt.exitStatus()); Out.str("\n"); |
| 9 | end; |
| 10 | |
| 11 | proc main*: INT; |
| 12 | var a: [2]INT; i: INT; |
| 13 | begin |
| 14 | _ := Rt.atExit(report); |
| 15 | i := 5; |
| 16 | a[i] := 1; |
| 17 | return 0; |
| 18 | end; |
| 19 | |
| 20 | end StopStatus. |