aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/data-model-14.c
blob: 1dbcb70112303d01fa04a539e4c3b42034773b8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#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'" } */
}