| 1 |
#include <stdio.h> |
| 2 |
#include <assert.h> |
| 3 |
#include <unistd.h> |
| 4 |
|
| 5 |
static int saw_ctor; |
| 6 |
static int saw_dtor; |
| 7 |
static int done_main; |
| 8 |
|
| 9 |
struct test_class { |
| 10 |
test_class () { |
| 11 |
m = new char[10]; |
| 12 |
printf("In ctor\n"); |
| 13 |
saw_ctor = 1; |
| 14 |
} |
| 15 |
~test_class () { |
| 16 |
delete m; |
| 17 |
printf("In dtor\n"); |
| 18 |
assert(done_main); |
| 19 |
saw_dtor = 1; |
| 20 |
_exit(0); |
| 21 |
} |
| 22 |
char * m; |
| 23 |
} g; |
| 24 |
|
| 25 |
int main() |
| 26 |
{ |
| 27 |
printf("In main\n"); |
| 28 |
assert(saw_ctor == 1); |
| 29 |
assert(saw_dtor == 0); |
| 30 |
done_main = 1; |
| 31 |
return 1; |
| 32 |
} |