<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 - Some symbols are not built / undefined when used in decltype"
href="https://bugs.llvm.org/show_bug.cgi?id=44438">44438</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Some symbols are not built / undefined when used in decltype
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</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>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>julien@vivenot.fr
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Hi,
Actual results:
The following reduced test case fails to build A<C1>::foo.
It results in a failed link :
$ clang++ test.cpp
/apps/dist/el6_gcc-9.2.0-64/bin/ld: /tmp/test-172f58.o:
(.rodata._ZTV1AI2C1E[_ZTV1AI2C1E]+0x10): undefined reference to `A<C1>::foo()'
clang-9: error: linker command failed with exit code 1 (use -v to see
invocation)
Expected results:
Executable should build and link just fine, including this A<C1>::foo symbol
which is used here.
Build date and results :
I personally tested on :
clang version 9.0.1 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
c1a0a213378a458fbea1a5c77b315c7dce08fd05)
Target: x86_64-unknown-linux-gnu
But I get similar results (missing A<C1>::foo) on godbolt for all versions
between 6.0.0 and trunk.
Additional information:
- Adding trailing return type information on 'Dispatcher::operator' return type
fixes the issue. Although it just repeats whats stated on the only return
instance.
- Replacing 'dispatch' trailing return type with the actual type fixes the
issue.
Test case:
#include <type_traits>
struct C1{};
struct C2{};
struct C3{};
struct IFace
{
virtual void foo() = 0;
};
template <class T>
struct A : IFace
{
void foo() override {};
};
template <template<typename> class F, typename Closure>
constexpr auto dispatch(int major, Closure fn)
// (*) the following does not build A<C1>::foo
-> decltype(F<C1>{}(fn))
// (*) the following links (and builds A<C1>::foo)
//-> IFace*
{
if (major == 1) return F<C1>{}(fn);
if (major == 2) return F<C2>{}(fn);
if (major == 3) return F<C3>{}(fn);
return decltype(F<C1>{}(fn)){};
}
template <class Cn>
struct Dispatcher
{
template<typename Closure>
constexpr decltype(auto) operator()(Closure fn)
// (*) adding the following also builds A<C1>::foo
// -> decltype(fn(Cn{}))
{
return fn(Cn{});
}
};
int main()
{
int i = 1;
auto f = [](auto t) -> IFace*
{
return new A<decltype(t)>;
};
auto a = dispatch<Dispatcher>(i, f);
return 1;
}</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>