https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127569
Bug ID: 127569
Summary: -Wanalyzer-use-after-free false negative
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
I believed the following program would be of course trivially diagnosed, but
was surprised to see that I couldn't manage to diagnose it under any
combination of flags and optimization levels.
alx@debian:~/tmp$ cat free.c
#include <stdlib.h>
#include <string.h>
char *
f(const char *s)
{
char *dup;
dup = strdup(s);
if (dup == NULL)
return NULL;
if (strlen(dup) == 42)
free(dup);
return dup;
}
alx@debian:~/tmp$ gcc -Wall -Wextra -O3 -fanalyzer -flto -c free.c
alx@debian:~/tmp$