<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 - Complex nested lambda crashes Clang frontend"
href="https://bugs.llvm.org/show_bug.cgi?id=43120">43120</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Complex nested lambda crashes Clang frontend
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.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>jonathan.barnard@grasshopperasia.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=22430" name="attach_22430" title="The Clang stack trace">attachment 22430</a> <a href="attachment.cgi?id=22430&action=edit" title="The Clang stack trace">[details]</a></span>
The Clang stack trace
The following C++17 code causes the compiler to crash, when compiling with
-std=c++17 -O0 -emit-llvm:
#include <functional>
#include <type_traits>
template <typename F>
constexpr auto curry(F&& f) {
if constexpr (std::is_invocable_v<F>) {
return f();
} else {
return [f = static_cast<F&&>(f)](auto&& arg) mutable {
return curry([
f = static_cast<F&&>(f),
arg_t = std::forward_as_tuple(static_cast<decltype(arg)&&>(arg))
](auto&&... args) mutable->decltype(f(static_cast<decltype(arg)&&>(arg),
static_cast<decltype(args)&&>(
args)...)) {
return std::apply(
f, std::tuple_cat(std::move(arg_t),
std::forward_as_tuple(
static_cast<decltype(args)&&>(args)...)));
});
};
}
}
int main(){
int n;
auto f = [](int n, int m, int x) { return n + m + x; };
auto c1 = curry(f)(n);
return 0;
}
<a href="https://godbolt.org/z/_iWHWd">https://godbolt.org/z/_iWHWd</a> is a link demonstrating it. It crashes on x86-64
Clang 8.0 and trunk, but seems not to crash on the Experimental Concepts Clang
build.</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>