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/55874] New: Incorrect warning location for uninitialized variable


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: unassigned@gcc.gnu.org
        ReportedBy: steven@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.


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