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;
   ^~~

Reply via email to