[llvm-bugs] [Bug 26640] New: Unitialized variable usage not checked in some cases
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 16 12:08:29 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26640
Bug ID: 26640
Summary: Unitialized variable usage not checked in some cases
Product: clang
Version: 3.8
Hardware: PC
OS: FreeBSD
Status: NEW
Severity: normal
Priority: P
Component: Driver
Assignee: unassignedclangbugs at nondot.org
Reporter: bdrewery at FreeBSD.org
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
cat > test.c << EOF
#include <stdlib.h>
int main() {
char *p;
int maybe_set_p = 0, flag = 1;
if (maybe_set_p)
p = (char*)malloc(1);
if (flag && p)
;
return 0;
}
EOF
clang38 -Wall -o test test.c
No warning is given about the uninitialized use of p in 'if (flag && p)'.
Changing the 'if (maybe_set_p)' to 'if (0)' shows the warning:
example.c:10:15: warning: variable 'p' is uninitialized when used here
[-Wuninitialized]
if (flag && p)
^
example.c:4:10: note: initialize the variable 'p' to silence this warning
char *p;
^
= NULL
2 warnings generated.
--
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/20160216/017bfee8/attachment.html>
More information about the llvm-bugs
mailing list