| 1 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */ |
| 2 |
|
| 3 |
/* Reproducer for PR analyzer/97258: we should report the double-free |
| 4 |
inside a static callback if the callback escapes. */ |
| 5 |
|
| 6 |
#include <stdlib.h> |
| 7 |
|
| 8 |
static void callback_1 (void *p) |
| 9 |
{ |
| 10 |
free (p); |
| 11 |
free (p); /* { dg-warning "double-'free' of 'p'" } */ |
| 12 |
} |
| 13 |
|
| 14 |
struct ops { |
| 15 |
void (*cb) (void *); |
| 16 |
}; |
| 17 |
|
| 18 |
static const struct ops ops_1 = { |
| 19 |
.cb = callback_1 |
| 20 |
}; |
| 21 |
|
| 22 |
extern void registration (const void *); |
| 23 |
|
| 24 |
void register_1 (void) |
| 25 |
{ |
| 26 |
registration (&ops_1); |
| 27 |
} |