<html>
<head>
<base href="https://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 --- - Use of parameter within template parameter of default argument" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24174&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=3gBYoaaMVHz7ufGJ3gh0HDSK8OhT74sgi4WtO73wHI4&s=x3JbZ5LuPpmdSZ0pDM3x_ziGTyBok7zI19VWY2Op8hE&e=">24174</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Use of parameter within template parameter of default argument
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows XP
</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>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.godfrey99@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Clang compiles the following code on trunk:
template<int>
constexpr int variable{};
int main() {
auto f = [] (auto x, int = variable<x>) {};
f(0, 0);
}
Even though the default argument is never used the code should still fail since
parameters are not allowed anywhere outside an unevaluated operand in a
function declaration.
When the second argument is used (i.e f(0)) or we replace auto with int we get
an error:
error: non-type template argument is not a constant expression
auto f = [] (auto x, int = variable<x>) {};
^
note: in instantiation of default function argument expression for
'operator()<int>' required here
f(0);
^
note: read of non-const variable 'x' is not allowed in a constant expression
auto f = [] (auto x, int = variable<x>) {};
But this error should read more or less like the following:
error: default argument references parameter 'x'
It seems clang does not perform the same error checking when parameter names
are used as non-type template arguments.</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>