https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63943
Bug ID: 63943
Summary: -Wmaybe-uninitialized pragma mishandled in inlined
function
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: eggert at gnu dot org
Created attachment 34031
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34031&action=edit
Program with -Wmaybe-uninitialized problem
Compile the attached program t.c with "gcc -Wmaybe-uninitialized -O2 -c t.c" on
x86-64 with GCC 4.9.2, and the output will be:
t.c: In function 'main':
t.c:17:3: warning: '*((void *)&v+4)' may be used uninitialized in this function
[-Wmaybe-uninitialized]
return argc < 1 ? !argv : dereference (v + 1);
^
'#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"' is in effect when the
possibly-uninitialized variable is used, but this use is in a function that GCC
inlined, and GCC is incorrectly warning based on the pragma setting in the
calling function, not based on the pragma setting where the dereferencing
actually occurs.
The problem does not occur with GCC 4.8.3 so this appears to be a regression.
The problem also goes away if I add '__attribute__((noinline))' to the
'dereference' function, so this appears to be related to inlining.
I ran into this problem while thinking about enabling -Werror when compiling
glibc; my first cut at this ran into the above problem.