<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 --- - Clang asserts when checked for overloaded binary operator supplied with a default argument"
href="http://llvm.org/bugs/show_bug.cgi?id=20911">20911</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang asserts when checked for overloaded binary operator supplied with a default argument
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>sgundapa@codeaurora.org
</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>Created <span class=""><a href="attachment.cgi?id=13022" name="attach_13022" title="unit test case">attachment 13022</a> <a href="attachment.cgi?id=13022&action=edit" title="unit test case">[details]</a></span>
unit test case
I have attached the pre-processed test case for your reference.
Sample compilation line
clang++ -target arm-none-linux-gnueabi -mcpu=cortex-a9 -O2 test.ii -c
clang-3.6:
/prj/llvm-arm/home/nightly/src/community-mainline/llvm/tools/clang/include/clang/AST/Expr.h:134:
void clang::Expr::setType(clang::QualType): Assertion `(t.isNull() ||
!t->isReferenceType()) && "Expressions can't have reference type"' failed.
The original test case is supposed to generate an error as per C++ standard
since operator+ can not have default arguments.
g++ -c test.ii generated the following diagnostic
test.c:7:30: error: 's' was not declared in this scope
Sam operator+(Sam &x, Sam &y=s);
^
test.c:7:31: error: 'Sam operator+(Sam&, Sam&)' cannot have default arguments
Sam operator+(Sam &x, Sam &y=s);
^
test.c: In function 'Sam operator+(Sam&, Sam&)':
test.c:10:12: error: could not convert '(x.Sam::i + y.Sam::i)' from 'int' to
'Sam'
return x.i+y.i;</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>