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
          Reporter: mpolacek at gcc dot
  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
     ret = empty_array[i];

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;

Reply via email to