<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 --- - Infinite loopo segfaults with optimisation level 1 and above"
href="http://llvm.org/bugs/show_bug.cgi?id=16733">16733</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Infinite loopo segfaults with optimisation level 1 and above
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.1
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>troels.roennow@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>If the following code is compiled with optimisation level 1, 2 or 3, it
segfaults. With optimsation level 0 it hangs forever as it is supposed to.
ex.cpp:
-------
#include<iostream>
void test() {
for(std::size_t n = 1; n < 4 ;++n )
n >>=1;
}
int main() {
test();
}
Bash:
-----
$ clang++ -O1 ex.cpp -o program
$ ./program
Segmentation fault: 11
$ clang++ --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
Note that the function call is essential. This code:
#include<iostream>
int main() {
for(std::size_t n = 1; n < 4 ;++n )
n >>=1;
}
works.</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>