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



             Bug #: 55874

           Summary: Incorrect warning location for uninitialized variable

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: middle-end

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: ste...@gcc.gnu.org





$ cat t.c

void bar (void);

int foo (int b, int c, int d)

{

  int res, r = 0;

  if (b)

    res = b * 2 + 4;

  if (c)

    {

      if (d)

        r = res;

      else

        __builtin_unreachable ();

    }

  return r;

}

$ ./xgcc -B. -O2 -W -Wall -Wextra t.c

t.c: In function 'foo':

t.c:14:3: warning: 'res' may be used uninitialized in this function 

[-Wmaybe-uninitialized]

   return r;

   ^

$ 



The warning is correct, but I'd expect the caret to point to res, not to

the return statement.

Reply via email to