<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 --- - Wrong constant folding"
href="http://llvm.org/bugs/show_bug.cgi?id=15959">15959</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong constant folding
</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>ishiura-compiler@ml.kwansei.ac.jp
</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>LLVM (git) + clang (3.4) for x86_64 miscompiles the following code.
$ cat error.c
int main (void)
{
volatile short x = 1;
static long k = 1L;
int a = x << ( k - 1 ); // a = 1
long t = 1L >> a ; // t = 0
if ( t != 0L ) { __builtin_abort(); }
return 0;
}
$ clang error.c -O1
$ ./a.out
Aborted (core dumped)
The following code with variable k replaced by "1L" is
correctly compiled.
$ cat noerror.c
int main (void)
{
volatile short x = 1;
int a = x << ( 1L - 1 ); // a = 1
long t = 1L >> a ; // t = 0
if ( t != 0L ) { __builtin_abort(); }
return 0;
}
$ clang noerror.c -O1
$ ./a.out
$ echo $?
0
$ clang -v
clang version 3.4 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
dd256314cf391063329e504f0ece46ee51bbfa2a) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
51dab6e3945a6d06a713869967ced3a8f9fb6294)
Target: x86_64-unknown-linux-gnu
Thread model: posix</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>