<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Unitialized variable usage not checked in some cases"
href="https://llvm.org/bugs/show_bug.cgi?id=26640">26640</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unitialized variable usage not checked in some cases
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bdrewery@FreeBSD.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>