Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/pr106539.c

raw
1 /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */
2
3 #include <stdlib.h>
4
5 void *test (void)
6 {
7 void **p = (void **)malloc (sizeof (void *) * 2);
8 if (!p)
9 return NULL;
10 p[0] = malloc(10);
11 p[1] = malloc(20); /* { dg-message "allocated here" } */
12 void *q = realloc (p, sizeof (void *)); /* { dg-message "when '\[^\n\r\]*realloc\[^\n\r\]*' succeeds, moving buffer" } */
13 if (!q)
14 /* { dg-warning "leak of '<unknown>'" "leak of unknown" { target *-*-* } .-1 } */
15 return p;
16 return q;
17 }