http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59225

            Bug ID: 59225
           Summary: missing maybe uninitialized warning following single
                    if
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net

With:
* gcc-4.8 (Debian 4.8.2-5) 4.8.2
* gcc (Debian 20131021-1) 4.9.0 20131021 (experimental) [trunk revision 203899]

xvii:~> cat tst1.c
int foo (int x)
{
  int y;
  if (x == 0)
    y = 1;
  return y;
}

"gcc-snapshot -O2 -Wuninitialized -c tst1.c" doesn't emit any warning.

If I change the code to:

xvii:~> cat tst2.c
int foo (int x)
{
  int y;
  if (x == 0)
    y = 1;
  else if (x == 1)
    y = 2;
  return y;
}

I get the following warning as expected:

tst2.c:8:3: warning: 'y' may be used uninitialized in this function
[-Wmaybe-uninitialized]
   return y;
   ^

Reply via email to