<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 --- - ubsan: Left shift of negative value in c89"
href="http://llvm.org/bugs/show_bug.cgi?id=17490">17490</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ubsan: Left shift of negative value in c89
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>silvas@purdue.edu
</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>c89 doesn't seem to have the "If E1 has a signed type and nonnegative value,
and E1 × 2^E2 is representable in the result type, then that is the resulting
value; otherwise, the behavior is undefined." wording, so this diagnostic is
spurious:
sean:~/tmp % cat left_shift_negative.c
int main(int argc, char **argv) {
return (-argc) << 2;
}
sean:~/tmp % clang -std=c89 -fsanitize=undefined left_shift_negative.c
sean:~/tmp % ./a.out
left_shift_negative.c:2:18: runtime error: left shift of negative value -1</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>