aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-3.c
blob: 3dcfae8f0a296118d4c98c4885ea211695ef3d2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdlib.h>

void *
calls_malloc (void)
{
  void *result = malloc (1024);
  return result;
}

void
calls_free (void *victim)
{
  free (victim); /* { dg-warning "double-'free' of 'victim'" } */
  /* TODO: this would be better emitted at the callsite,
     for such a simple wrapper.  */
}

void test (void)
{
  void *ptr = calls_malloc ();
  calls_free (ptr);
  calls_free (ptr); /* BUG: double-'free'.  */
}