[LLVMbugs] [Bug 22318] New: No -Wuninitialized warning on uninitialized array element.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 23 15:16:05 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22318

            Bug ID: 22318
           Summary: No -Wuninitialized warning on uninitialized array
                    element.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$: cat s.c
int f1() {
  int arr[2][2];
  return arr[0][0];
}

int f2() {
  int a;
  return a;
}
$: 
$: clang-trunk -c -Weverything -Wno-missing-prototypes s.cs.c:8:10: warning:
variable 'a' is uninitialized when used here
      [-Wuninitialized]
  return a;
         ^
s.c:7:8: note: initialize the variable 'a' to silence this warning
  int a;
       ^
        = 0
1 warning generated.
$: 
$: gcc-trunk -c -Wall s.c
s.c: In function ‘f1’:
s.c:3:10: warning: ‘arr[0][0]’ is used uninitialized in this function
[-Wuninitialized]
   return arr[0][0];
          ^
s.c: In function ‘f2’:
s.c:8:10: warning: ‘a’ is used uninitialized in this function [-Wuninitialized]
   return a;
          ^
$:

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150123/00809e72/attachment.html>


More information about the llvm-bugs mailing list