[llvm-bugs] [Bug 37089] New: clang does not generate a template instance in a very specific case
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 11 08:58:29 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37089
Bug ID: 37089
Summary: clang does not generate a template instance in a very
specific case
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: blastrock at free.fr
CC: llvm-bugs at lists.llvm.org
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++.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180411/28b42c43/attachment.html>
More information about the llvm-bugs
mailing list