This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/81782] New: Yet another -Wmaybe-uninitialized false positive with empty array


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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]