Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / Wuse-after-free.c
blob9862de5c0a9c179040e2be692bf2f25b02294733
1 /* PR middle-end/104069 - -Werror=use-after-free false positive on
2 elfutils-0.186
3 { dg-do compile }
4 { dg-options "-Wall" } */
6 typedef __SIZE_TYPE__ size_t;
8 extern void* realloc (void *, size_t);
10 void* __libdw_unzstd (size_t todo)
12 void *sb = 0;
14 for ( ; ; )
16 // Ran only once.
17 if (!sb)
19 char *b = realloc (sb, todo);
20 if (!b)
21 break;
23 sb = b;
26 todo -= 1;
27 if (todo == 0)
28 break;
31 // Shrink buffer: leave only one byte for simplicity.
32 char *b = realloc (sb, 1);
33 if (b)
34 sb = b;
35 else
37 // Realloc failed mysteriously, leave 'sb' untouched.
40 return sb; // { dg-bogus "-Wuse-after-free" }