<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 --- - parser crash for overloaded operator++ and ?:"
href="http://llvm.org/bugs/show_bug.cgi?id=15628">15628</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>parser crash for overloaded operator++ and ?:
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.2
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm@brianandresen.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>Created <span class=""><a href="attachment.cgi?id=10257" name="attach_10257" title="test case">attachment 10257</a> <a href="attachment.cgi?id=10257&action=edit" title="test case">[details]</a></span>
test case
Clang 3.2 crashed while parsing some code, which compiles okay using GCC 4.7.2
and Visual Studio 2010/2012.
I distilled out a simpler test case. The key problem seems to be an expression
with an overloaded operator++, given directly as the guard expression for the
ternary operator ?:. I found several workarounds, described below.
---
class BlockInputIter
{
public:
void* operator++(int);
void* next();
};
bool f()
{
BlockInputIter nextInput;
return nextInput++ ? false : true; // *** clang 3.2 parser failure ***
}
// Adding an explicit comparison to 0 is a workaround.
bool workaround1()
{
BlockInputIter nextInput;
return ( nextInput++ != 0 ) ? false : true;
}
// Even just adding parentheses around the "nextInput++" expression works.
bool workaround2()
{
BlockInputIter nextInput;
return ( nextInput++ ) ? false : true;
}
// If a function is used, instead of an operator overload, there's no problem.
bool workaround3()
{
BlockInputIter nextInput;
return nextInput.next() ? false : true;
}</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>