| 1 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
|
| 5 |
void * |
| 6 |
calls_malloc (void) |
| 7 |
{ |
| 8 |
void *result = malloc (1024); |
| 9 |
return result; |
| 10 |
} |
| 11 |
|
| 12 |
void |
| 13 |
calls_free (void *victim) |
| 14 |
{ |
| 15 |
free (victim); /* { dg-warning "double-'free' of 'victim'" } */ |
| 16 |
/* TODO: this would be better emitted at the callsite, |
| 17 |
for such a simple wrapper. */ |
| 18 |
} |
| 19 |
|
| 20 |
void test (void) |
| 21 |
{ |
| 22 |
void *ptr = calls_malloc (); |
| 23 |
calls_free (ptr); |
| 24 |
calls_free (ptr); /* BUG: double-'free'. */ |
| 25 |
} |