[llvm-bugs] [Bug 43120] New: Complex nested lambda crashes Clang frontend
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 27 02:04:35 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43120
Bug ID: 43120
Summary: Complex nested lambda crashes Clang frontend
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: jonathan.barnard at grasshopperasia.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Created attachment 22430
--> https://bugs.llvm.org/attachment.cgi?id=22430&action=edit
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;
}
https://godbolt.org/z/_iWHWd 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.
--
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/20190827/7f56e0ee/attachment-0001.html>
More information about the llvm-bugs
mailing list