[Bug middle-end/78915] New: missing -Wuninitialized accessing allocated memory
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 23 23:35:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78915
Bug ID: 78915
Summary: missing -Wuninitialized accessing allocated memory
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
All three functions in the test case below read uninitialized memory but only
f0 is diagnosed with the -Wuninitialized warning. All three should be.
$ cat z.c && gcc -O2 -S -Wall -Wextra -Wpedantic z.c
int f0 (void)
{
int i;
++i;
return i;
}
int f1 (unsigned n)
{
int *p = (int*)__builtin_alloca (n);
++*p;
return *p;
}
int f2 (unsigned n)
{
int *p = (int*)__builtin_malloc (n);
if (!p)
return -1;
++*p;
return *p;
}
z.c: In function ‘f0’:
z.c:5:3: warning: ‘i’ is used uninitialized in this function [-Wuninitialized]
++i;
^~~
More information about the Gcc-bugs
mailing list