<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 - "Recursive template instantiation exceeded maximum depth" for innocent-looking code."
href="https://bugs.llvm.org/show_bug.cgi?id=44650">44650</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>"Recursive template instantiation exceeded maximum depth" for innocent-looking code.
</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>officesamurai@gmail.com
</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>Created <span class=""><a href="attachment.cgi?id=23050" name="attach_23050" title="The original test case">attachment 23050</a> <a href="attachment.cgi?id=23050&action=edit" title="The original test case">[details]</a></span>
The original test case
I've got this problem on Alpine Linux originally.
<<<
# cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.2
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="<a href="https://alpinelinux.org/">https://alpinelinux.org/</a>"
BUG_REPORT_URL="<a href="https://bugs.alpinelinux.org/">https://bugs.alpinelinux.org/</a>"
# clang -v
Alpine clang version 9.0.0 (<a href="https://git.alpinelinux.org/aports">https://git.alpinelinux.org/aports</a>
f7f0d2c2b8bcd6a5843401a9a702029556492689) (based on LLVM 9.0.0)
Target: x86_64-alpine-linux-musl
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation:
/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/9.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/9.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
# clang++ -c test_alpine1.cpp
In file included from test_alpine1.cpp:1:
In file included from
/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../include/c++/9.2.0/functional:58:
/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../include/c++/9.2.0/bits/refwrap.h:303:46:
fatal error: recursive template instantiation exceeded maximum depth of 1024
template<typename _Up, typename _Up2 = __remove_cvref_t<_Up>>
...
<span class="quote">>>></span >
test_alpine1.cpp:
<<<
#include <functional>
using function = std::function<void()>;
struct S
{
S(std::reference_wrapper<function>)
{
}
void operator()() const
{
}
};
auto test()
{
function f;
return S(std::ref(f));
}
<span class="quote">>>></span >
The interesting thing here is that if I remove S::operator(), the compilation
succeeds.
P.S. I've tried to minimize it further by replacing std::function with a
trivial struct and in the resulting code the operator() is no longer needed to
reproduce the error (see test_alpine2.cpp).
P.S.2 I've also tried to get rid of things specific to the stdlib used on
Alpine and got test_anywhere.cpp, which fails to compile with the same error on
other systems as well. Namely, I've tried it on LinuxMint 17.3 where I have
more versions of Clang installed and it fails virtually for all of them (4.x -
9.x).
P.S.3 GCC is able to compile all of the files.</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>