<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 --- - warn on conditions that are too late to check for undefined behaviour"
href="http://llvm.org/bugs/show_bug.cgi?id=16868">16868</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>warn on conditions that are too late to check for undefined behaviour
</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>All
</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>nlewycky@google.com
</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>Examples:
bool test(int *p) {
int i = *p;
if (!p)
return false;
// ... continue using i
}
We should warn on the condition, because if the condition is ever true then
undefined behaviour must have already occurred. (Similarly on 'p' and the
condition being false.)
bool test2(int idx) {
char arr[100];
arr[idx] = '\0';
if (idx < 0 || idx >= 100) // either of these alone should also suffice to
warn
return false;
// ...
}
Examples putting the overflow inside the condition expression:
bool test3(int x) {
if ((x+1) < x)
...
bool test4(int x, int y) {
if (x != (x*y)/y)
...</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>