<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 --- - code with volatile struct produces wrong result at -O3 on x86_64-linux-gnu"
href="http://llvm.org/bugs/show_bug.cgi?id=16521">16521</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>code with volatile struct produces wrong result at -O3 on x86_64-linux-gnu
</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>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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>su@cs.ucdavis.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>The following code produces incorrect result when compiled with the current
clang trunk at -O3 on x86_64-linux (in both 32-bit and 64-bit modes). This is a
regression as both clang 3.2 and 3.3 produce correct code.
$ clang-trunk -v
clang version 3.4 (trunk 185306)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -O2 reduced.c
$ a.out
0
$ clang-trunk -O3 reduced.c
$ a.out
1
$ clang-3.3 -O3 reduced.c
$ a.out
0
$ clang-3.2 -O3 reduced.c
$ a.out
0
------------------------------------
int printf (const char *, ...);
int a, b, c, d, e = 1;
struct S
{
int f;
};
volatile struct S s;
void foo (int *p)
{
int i;
for (i = 0; i < 4; i++) {
int t[2] = {0, 0};
for (; b < 2; b++) {
d = 0;
for (; d >= 0; d--)
c = 0;
for (; c < 7; c++)
t[1] ^= 1;
}
if (t[1]) {
s;
*p = e;
}
}
}
int main ()
{
foo (&a);
printf ("%d\n", a);
return 0;
}</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>