<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - Compiler confused when compiling template variable initialized by lambda-expression with default parameter."
href="https://bugs.llvm.org/show_bug.cgi?id=34005">34005</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler confused when compiling template variable initialized by lambda-expression with default parameter.
</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>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>shirayama.kazatsuyu@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The code below fail to be compile.
// prog.cc
template<int> struct X {};
template<int n> constexpr void f(X<n>) {}
template<typename> constexpr int v = [](int r = 0l) constexpr { return r; }();
int main() {
f<v<int>>(X<0>());
}
$ clang++ -std=c++1z prog.cc
prog.cc:6:5: error: no matching function for call to 'f'
f<v<int>>(X<0>());
^~~~~~~~~
prog.cc:2:32: note: candidate function not viable: no known conversion from
'X<...>' to 'X<...>' for 1st argument
template<int n> constexpr void f(X<n>) {}
^
1 error generated.
I think v<T> is always 0, so f<v<int>>(X<0>()) should match f<0>(X<0>);
And if lambda's default parameter type is int,
template<typename> constexpr int v = [](int r = 0) constexpr { return r; }();
There are no errors.
This link is the result executed by wandbox.
<a href="https://wandbox.org/permlink/yjKqrYKQyl2YZ6PO">https://wandbox.org/permlink/yjKqrYKQyl2YZ6PO</a></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>