This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/81782] New: Yet another -Wmaybe-uninitialized false positive with empty array
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 09 Aug 2017 12:19:52 +0000
- Subject: [Bug middle-end/81782] New: Yet another -Wmaybe-uninitialized false positive with empty array
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81782
Bug ID: 81782
Summary: Yet another -Wmaybe-uninitialized false positive with
empty array
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
I hope this isn't a duplicate of one of the many similar PRs. This one happens
with -O0. Also, if you remove the (int) cast, the warning disappears, because
then we get rid of the if conditional.
$ ./cc1 -quiet w.c -Wall
w.c: In function ‘foo’:
w.c:8:22: warning: ‘empty_array[i]’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
ret = empty_array[i];
~~~~~~~~~~~^~~
int
foo (void)
{
char empty_array[] = { };
int i, ret = 0;
for (i = 0; i < (int) (sizeof (empty_array) / sizeof (empty_array[0])); i++)
ret = empty_array[i];
return ret;
}