aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/callbacks-2.c
blob: 98915ee617bd23b24e8a7a370f0271f273c2206f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Reproducer for PR analyzer/97258: we should report the double-free
   inside a static callback if the callback is accessible via a global
   initializer.  */

#include <stdlib.h>

static void callback_1 (void *p)
{
  free (p);
  free (p); /* { dg-warning "double-'free' of 'p'" } */
}

struct ops {
  void (*cb) (void *);
};

/* Callback struct is not static, and so could be accessed via
   another TU.  */

const struct ops ops_1 = {
  .cb = callback_1
};