https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101584
Bug ID: 101584
Summary: missing -Wuninitialized with an allocated object after
a built-in call
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The puts() calls below should be diagnosed by -Wuninitialized but aren't
because the alias analysis the warning relies on determines that the argument
and the result returned by malloc() or the VLA might alias each other.
$ cat a.c && gcc -O2 -S -Wall /build/tmp/a.c
void f (const char *s)
{
char *p = __builtin_malloc (__builtin_strlen (s));
__builtin_printf ("%s", s);
__builtin_puts (p); // missing -Wununitialized
}
void g (const char *s)
{
char a[__builtin_strlen (s)];
__builtin_printf ("%s", s);
__builtin_puts (a); // missing -Wununitialized
}