blob: 9400ae2fd7abb3d2eddfc15e963f40cacbdc476e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */
#include <stdlib.h>
void *global_ptr;
void test_1 (int i)
{
global_ptr = malloc (1024); /* { dg-message "allocated here" } */
*(int *)&global_ptr = i; /* { dg-warning "leak of 'global_ptr'" } */
}
void test_2 (int i)
{
void *p = malloc (1024); /* { dg-message "allocated here" } */
global_ptr = p;
*(int *)&p = i;
p = global_ptr;
free (p);
free (global_ptr); /* { dg-warning "double-'free' of 'p'" } */
}
|