<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 --- - possible wrong code bug"
href="http://llvm.org/bugs/show_bug.cgi?id=17473">17473</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>possible wrong code bug
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>regehr@cs.utah.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>Well this one is weird since fn2 isn't even called, but it can't be removed or
the bad behavior goes away.
[regehr@imp r104]$ clang -w -O0 small.c ; ./a.out
ffffffff
[regehr@imp r104]$ clang -w -O small.c ; ./a.out
ff
[regehr@imp r104]$ gcc -w -O small.c ; ./a.out
ffffffff
[regehr@imp r104]$ cat small.c
int printf(const char *, ...);
int a, c, d, e, f, g, i, j;
short b;
char h;
int fn1(void)
{
return b && a > b || b < 0 && a ?: b;
}
void fn2(void) {
for (;; f = fn1())
;
}
void fn3(int p1) {
j &&(c = 0 ?: 0);
g = p1;
}
int main(void) {
for (h = 0; h >= 0; ++h) {
fn3(h);
i = d >= 0 ?: 0;
}
e = g;
e += h;
printf("%x\n", e);
return 0;
}
[regehr@imp r104]$ clang -v
clang version 3.4 (trunk 191880)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6</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>