ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
with_gc
Last change
on this file since 948b0c8 was ff7ff14a, checked in by Andrew Beach <ajbeach@…>, 8 years ago |
Discovered a case where the memory management didn't work, stricter tracking of the current exception fixes the issue.
|
-
Property mode
set to
100644
|
File size:
900 bytes
|
Rev | Line | |
---|
[86d5ba7c] | 1 | // Draft memory management test. (remember -fexceptions)
|
---|
| 2 |
|
---|
| 3 | #include <stdio.h>
|
---|
| 4 |
|
---|
| 5 | int main()
|
---|
| 6 | {
|
---|
| 7 | try {
|
---|
| 8 | throw 3;
|
---|
| 9 | }
|
---|
| 10 | catch( 3 ) {
|
---|
| 11 | printf("First Caught\n");
|
---|
| 12 | try {
|
---|
| 13 | throw 4;
|
---|
| 14 | }
|
---|
| 15 | catch( 4 ) {
|
---|
| 16 | printf("Both Caught\n");
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 | printf("Part A Complete\n");
|
---|
| 20 |
|
---|
| 21 | try {
|
---|
| 22 | try {
|
---|
| 23 | throw 2;
|
---|
| 24 | }
|
---|
| 25 | catch( 2 ) {
|
---|
| 26 | printf("First Catch and rethrow\n");
|
---|
| 27 | throw;
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 | catch( 2 ) {
|
---|
| 31 | printf("Second Catch\n");
|
---|
| 32 | }
|
---|
| 33 | printf("Part B Complete\n");
|
---|
| 34 |
|
---|
| 35 | try {
|
---|
| 36 | try {
|
---|
| 37 | throw 5;
|
---|
| 38 | }
|
---|
| 39 | catch( 5 ) {
|
---|
| 40 | printf("Throw before cleanup\n");
|
---|
| 41 | throw 6;
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 | catch( 6 ) {
|
---|
| 45 | printf("Catch after cleanup\n");
|
---|
| 46 | }
|
---|
| 47 | printf("Part C Complete\n");
|
---|
[ff7ff14a] | 48 |
|
---|
| 49 | try {
|
---|
| 50 | try {
|
---|
| 51 | throw 7;
|
---|
| 52 | }
|
---|
| 53 | catch( 7 ) {
|
---|
| 54 | printf("Caught initial throw.\n");
|
---|
| 55 | try {
|
---|
| 56 | throw 8;
|
---|
| 57 | }
|
---|
| 58 | catch( 8 ) {
|
---|
| 59 | printf("Caught intermediate throw.\n");
|
---|
| 60 | }
|
---|
| 61 | throw;
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | catch( 7 ) {
|
---|
| 65 | printf("Caught final throw.\n");
|
---|
| 66 | }
|
---|
| 67 | printf("Part D Complete\n");
|
---|
[86d5ba7c] | 68 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.