<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 recurses infinitely and exausts stack"
href="https://bugs.llvm.org/show_bug.cgi?id=43335">43335</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler recurses infinitely and exausts stack
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>brenorg@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>This code exhausts the stack:
struct Foo {
template <class... T>
Foo(T... a, decltype(Foo(a...))* = nullptr) {}
} foo(1);
<a href="https://godbolt.org/z/ahHavv">https://godbolt.org/z/ahHavv</a>
I wasn't sure if I should even report this because the code is obviously
broken. I decided to do so because:
1 - Maybe it is worth looking into as it could be indication of architectural
problem
2 - The error message could be better. I guess it should be possible to detect
this scenario and avoid infinite recursion.
3 - With this slight variation, clang give a more sane error message:
struct Foo {
template <class... T>
Foo(T... a, decltype(Foo(1))* = nullptr) {}
} foo(1);
<a href="https://godbolt.org/z/eo8zAX">https://godbolt.org/z/eo8zAX</a>
Fun fact: Both GCC and MSVC do not like this code.
<a href="https://godbolt.org/z/olrorn">https://godbolt.org/z/olrorn</a>
<a href="https://godbolt.org/z/BeDsBY">https://godbolt.org/z/BeDsBY</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>