<html>
<head>
<base href="http://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 --- - Right-hand side of logical expression gets speculated, causing jump on uninitialized value"
href="http://llvm.org/bugs/show_bug.cgi?id=21084">21084</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Right-hand side of logical expression gets speculated, causing jump on uninitialized value
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hans@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Consider the following:
void f();
bool ReadInt(int*);
void test() {
int local;
if (ReadInt(&local) && local < 8 && local >= 0)
f();
}
Compiled with Clang r218435:
$ bin/clang -O3 -S -o - /tmp/a.cc
.cfi_startproc
# BB#0:
pushq %rax
.Ltmp0:
.cfi_def_cfa_offset 16
leaq 4(%rsp), %rdi
callq _Z7ReadIntPi
cmpl $7, 4(%rsp) <---- Cmp with uninitialized stack value
ja .LBB0_3 <---- Valgrind gets upset
# BB#1:
testb %al, %al <---- Return value of ReadInt checked here
je .LBB0_3
# BB#2:
callq _Z1fv
.LBB0_3:
popq %rax
retq
While the asm looks like it works in practice, Valgrind (and I'd guess other
tools too) get upset about jumping based on an uninitialized value.</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>