<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 - clang does not generate a template instance in a very specific case"
href="https://bugs.llvm.org/show_bug.cgi?id=37089">37089</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang does not generate a template instance in a very specific case
</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>Linux
</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>C++14
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>blastrock@free.fr
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I have a strange bug where clang seems to forget to generate a template
instance.
Here is the code, reduced as much as I could:
template <class T>
T declval()
{
T* v = nullptr;
return *v;
}
template <class F, class... Args>
auto do_call(F func, Args&&... args) -> decltype(func(args...))
{
return func(args...);
}
template <class F, class... Args>
struct __func
{
virtual void buggy_method()
{
do_call(declval<F>(), Args{}...);
}
};
template <typename C>
void async_resumable(C cb)
{
auto l = [cb](auto&&... args) { cb(args...); };
__func<decltype(l), int> y;
}
int main()
{
async_resumable([&](auto) -> void { async_resumable([](int) {}); });
}
On clang 5, 6 and trunk, compiling this gives the following error:
$ /usr/bin/clang++-5.0 -std=c++14 -o /dev/null ok.ii
/tmp/ok-5eaa37.o:(.rodata+0x80): undefined reference to
`_ZN6__funcIZ15async_resumableIZZ4mainENK3$_0clIiEEvT_EUliE_EvS3_EUlDpOT_E_JiEE12buggy_methodEv'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
- If you remove the "-> void" in the last lambda, the symbol is generated and
the code compiles
- If you replace the "auto" argument in the last lambda by "int", it also works
- GCC 7 compiles the code successfully in all cases.
If it's of any matter, in real life, that __func class is the one in
std::function in libc++.</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>