[clang] ice taking lambda::operator() address
The following code crashes all recent versions of clang from v15.0.0 (tested up to 18.1.0), but compiles smoothly both with recent versions of both g++ and msvc. It used to compile also with clang v14.0.0:
#include <tuple>
#include <functional>
#include <utility>
template<typename T> T fake_get();
using type_list = std::tuple<int, char&, const float*, std::size_t&&, bool>;
template<typename T> struct analyzer_base {};
template<typename T> using analyzer = analyzer_base<decltype(&T::operator())>;
int main(int, char**)
{
std::invoke([]<std::size_t... i>(std::index_sequence<i...>)
{
(std::invoke([]<std::size_t... j>(auto k, std::index_sequence<j...>)
{
using return_type = std::tuple_element_t<k, type_list>;
using arguments_type = std::tuple<std::tuple_element_t<j, type_list>...>;
using lambda_type = decltype([](std::tuple_element_t<j, type_list>...) -> return_type { return fake_get<return_type>(); });
analyzer<lambda_type>{};
}, std::integral_constant<std::size_t, i>{}, std::make_index_sequence<i>{}), ...);
}, std::make_index_sequence<std::tuple_size_v<type_list> - 1>{});
}
>clang++ test.cpp -std=c++20
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/lib/llvm-18/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/jvilar -fcoverage-compilation-dir=/home/jvilar -resource-dir /usr/lib/llvm-18/lib/clang/18 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-191165.o -x c++ test.cpp
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. test.cpp:16:22: Generating code for declaration 'main(int, char **)::(anonymous class)::operator()(std::index_sequence<0UL, 1UL, 2UL, 3UL>)::(anonymous class)::operator()'
#0 0x00007f8e6f7e967f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x00007f8e6f7e77b9 llvm::sys::RunSignalHandlers() build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Signals.cpp:106:18
#2 0x00007f8e6f7e9dc0 SignalHandler build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x00007f8e6e5f3320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
#4 0x00007f8e77fb9351 use_empty build-llvm/tools/clang/stage2-bins/llvm/include/llvm/IR/Value.h:346:20
#5 0x00007f8e77fb9351 clang::CodeGen::CodeGenFunction::EmitReturnBlock() build-llvm/tools/clang/stage2-bins/clang/lib/CodeGen/CodeGenFunction.cpp:286:51
#6 0x00007fff734b4c50
clang++: error: unable to execute command: Segmentation fault
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 18.1.3 (1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/test-7765b2.cpp
clang++: note: diagnostic msg: /tmp/test-7765b2.sh
clang++: note: diagnostic msg:
********************
A live demo is in Compiler Explorer.
A zip with original c++ file, preprocessed file and run script is in test.zip
Also crashes in main: https://godbolt.org/z/Y6bhrox1W
Unreachable hit:
non-canonical or dependent type in IR-generation
Backtrace:
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:246!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:16:22: Generating code for declaration 'main(int, char **)::(anonymous class)::operator()(std::index_sequence<0UL, 1UL, 2UL, 3UL>)::(anonymous class)::operator()'
#0 0x000000000395f508 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x395f508)
#1 0x000000000395d1ec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x395d1ec)
#2 0x00000000038aeba8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007af811242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007af8112969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007af811242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007af8112287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00000000038b9e3a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38b9e3a)
#8 0x0000000003d060e2 clang::CodeGen::CodeGenFunction::getEvaluationKind(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d060e2)
#9 0x00000000040946e2 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40946e2)
#10 0x00000000040b692d clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40b692d)
#11 0x0000000003c9d3b5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c9d3b5)
#12 0x0000000003ca4bfc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ca4bfc)
#13 0x0000000003d076ba clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d076ba)
#14 0x0000000003d1b0ac clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d1b0ac)
#15 0x0000000003d7b102 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d7b102)
#16 0x0000000003d759b5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d759b5)
#17 0x0000000003d81acd clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81acd)
#18 0x0000000003d81a20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81a20)
#19 0x0000000003d81a20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81a20)
#20 0x0000000003d81a20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81a20)
#21 0x0000000003d81a20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81a20)
#22 0x0000000003d81a20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81a20)
#23 0x0000000003d81a20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81a20)
#24 0x0000000003d81a20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d81a20)
#25 0x0000000003d84373 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d84373)
#26 0x000000000422e1fe (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#27 0x000000000422cd15 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x422cd15)
#28 0x00000000062659ec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62659ec)
#29 0x000000000422bd28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x422bd28)
#30 0x00000000044ad629 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44ad629)
#31 0x00000000044356ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44356ee)
#32 0x000000000459440e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x459440e)
#33 0x0000000000c4eb3c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4eb3c)
#34 0x0000000000c47dca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x000000000426f569 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#36 0x00000000038af054 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38af054)
#37 0x000000000426fb5f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#38 0x0000000004235ef5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4235ef5)
#39 0x000000000423695d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x423695d)
#40 0x000000000423e6e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x423e6e5)
#41 0x0000000000c4bfd5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4bfd5)
#42 0x0000000000b2e2b4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb2e2b4)
#43 0x00007af811229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x00007af811229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x0000000000c478be _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc478be)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
Confirmed on 19.0 (trunk): https://godbolt.org/z/a3sTnx4b1 Reduced by me and C-Reduce:
struct integral_constant {
constexpr operator int() {
return 0;
}
};
template < typename _Tp, _Tp... >
struct integer_sequence {};
int main() {
[]< int... i >(integer_sequence<int, i... >) {
(
[](auto k, integer_sequence<int>) {
using lambda_type = decltype([] () -> decltype(k) { return {}; });
decltype(&lambda_type::operator()){};
}(integral_constant{}, __make_integer_seq<integer_sequence, int, i >{}),
...
);
}(integer_sequence<int, 0 >{});
}
Crash:
non-canonical or dependent type in IR-generation
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:246!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:13:7: Generating code for declaration 'main()::(anonymous class)::operator()(integer_sequence<int, 0>)::(anonymous class)::operator()'
#0 0x0000000003979e88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3979e88)
#1 0x0000000003977b6c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3977b6c)
#2 0x00000000038c9528 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000079ab30a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000079ab30a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000079ab30a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000079ab30a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00000000038d47ba (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38d47ba)
#8 0x0000000003d21402 clang::CodeGen::CodeGenFunction::getEvaluationKind(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d21402)
#9 0x00000000040afbe2 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40afbe2)
#10 0x00000000040d1e2d clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40d1e2d)
#11 0x0000000003cb8275 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cb8275)
#12 0x0000000003cbfcec clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cbfcec)
#13 0x0000000003d229da clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d229da)
#14 0x0000000003d365bc clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d365bc)
#15 0x0000000003d96602 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d96602)
#16 0x0000000003d90eb5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d90eb5)
#17 0x0000000003d9cfcd clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d9cfcd)
#18 0x0000000003d9cf20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d9cf20)
#19 0x0000000003d9f873 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d9f873)
#20 0x00000000042496fe (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#21 0x0000000004248215 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4248215)
#22 0x0000000006284e9c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6284e9c)
#23 0x0000000004247228 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4247228)
#24 0x00000000044c85b9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c85b9)
#25 0x000000000445067e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x445067e)
#26 0x00000000045af39e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45af39e)
#27 0x0000000000c4fcec cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4fcec)
#28 0x0000000000c48f7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x000000000428aa69 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#30 0x00000000038c99d4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38c99d4)
#31 0x000000000428b05f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#32 0x00000000042513f5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42513f5)
#33 0x0000000004251e5d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4251e5d)
#34 0x0000000004259be5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4259be5)
#35 0x0000000000c4d185 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4d185)
#36 0x0000000000b2f254 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb2f254)
#37 0x000079ab30a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x000079ab30a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x0000000000c48a6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc48a6e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
@llvm/issue-subscribers-clang-codegen
Author: None (jvcppdev)
#include <tuple>
#include <functional>
#include <utility>
template<typename T> T fake_get();
using type_list = std::tuple<int, char&, const float*, std::size_t&&, bool>;
template<typename T> struct analyzer_base {};
template<typename T> using analyzer = analyzer_base<decltype(&T::operator())>;
int main(int, char**)
{
std::invoke([]<std::size_t... i>(std::index_sequence<i...>)
{
(std::invoke([]<std::size_t... j>(auto k, std::index_sequence<j...>)
{
using return_type = std::tuple_element_t<k, type_list>;
using arguments_type = std::tuple<std::tuple_element_t<j, type_list>...>;
using lambda_type = decltype([](std::tuple_element_t<j, type_list>...) -> return_type { return fake_get<return_type>(); });
analyzer<lambda_type>{};
}, std::integral_constant<std::size_t, i>{}, std::make_index_sequence<i>{}), ...);
}, std::make_index_sequence<std::tuple_size_v<type_list> - 1>{});
}
>clang++ test.cpp -std=c++20
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/lib/llvm-18/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/jvilar -fcoverage-compilation-dir=/home/jvilar -resource-dir /usr/lib/llvm-18/lib/clang/18 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-191165.o -x c++ test.cpp
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. test.cpp:16:22: Generating code for declaration 'main(int, char **)::(anonymous class)::operator()(std::index_sequence<0UL, 1UL, 2UL, 3UL>)::(anonymous class)::operator()'
#<!-- -->0 0x00007f8e6f7e967f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:723:13
#<!-- -->1 0x00007f8e6f7e77b9 llvm::sys::RunSignalHandlers() build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Signals.cpp:106:18
#<!-- -->2 0x00007f8e6f7e9dc0 SignalHandler build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:413:1
#<!-- -->3 0x00007f8e6e5f3320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
#<!-- -->4 0x00007f8e77fb9351 use_empty build-llvm/tools/clang/stage2-bins/llvm/include/llvm/IR/Value.h:346:20
#<!-- -->5 0x00007f8e77fb9351 clang::CodeGen::CodeGenFunction::EmitReturnBlock() build-llvm/tools/clang/stage2-bins/clang/lib/CodeGen/CodeGenFunction.cpp:286:51
#<!-- -->6 0x00007fff734b4c50
clang++: error: unable to execute command: Segmentation fault
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 18.1.3 (1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/test-7765b2.cpp
clang++: note: diagnostic msg: /tmp/test-7765b2.sh
clang++: note: diagnostic msg:
********************
A live demo is in Compiler Explorer.
A zip with original c++ file, preprocessed file and run script is in test.zip
@llvm/issue-subscribers-c-20
Author: None (jvcppdev)
#include <tuple>
#include <functional>
#include <utility>
template<typename T> T fake_get();
using type_list = std::tuple<int, char&, const float*, std::size_t&&, bool>;
template<typename T> struct analyzer_base {};
template<typename T> using analyzer = analyzer_base<decltype(&T::operator())>;
int main(int, char**)
{
std::invoke([]<std::size_t... i>(std::index_sequence<i...>)
{
(std::invoke([]<std::size_t... j>(auto k, std::index_sequence<j...>)
{
using return_type = std::tuple_element_t<k, type_list>;
using arguments_type = std::tuple<std::tuple_element_t<j, type_list>...>;
using lambda_type = decltype([](std::tuple_element_t<j, type_list>...) -> return_type { return fake_get<return_type>(); });
analyzer<lambda_type>{};
}, std::integral_constant<std::size_t, i>{}, std::make_index_sequence<i>{}), ...);
}, std::make_index_sequence<std::tuple_size_v<type_list> - 1>{});
}
>clang++ test.cpp -std=c++20
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/lib/llvm-18/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/jvilar -fcoverage-compilation-dir=/home/jvilar -resource-dir /usr/lib/llvm-18/lib/clang/18 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-191165.o -x c++ test.cpp
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. test.cpp:16:22: Generating code for declaration 'main(int, char **)::(anonymous class)::operator()(std::index_sequence<0UL, 1UL, 2UL, 3UL>)::(anonymous class)::operator()'
#<!-- -->0 0x00007f8e6f7e967f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:723:13
#<!-- -->1 0x00007f8e6f7e77b9 llvm::sys::RunSignalHandlers() build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Signals.cpp:106:18
#<!-- -->2 0x00007f8e6f7e9dc0 SignalHandler build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:413:1
#<!-- -->3 0x00007f8e6e5f3320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
#<!-- -->4 0x00007f8e77fb9351 use_empty build-llvm/tools/clang/stage2-bins/llvm/include/llvm/IR/Value.h:346:20
#<!-- -->5 0x00007f8e77fb9351 clang::CodeGen::CodeGenFunction::EmitReturnBlock() build-llvm/tools/clang/stage2-bins/clang/lib/CodeGen/CodeGenFunction.cpp:286:51
#<!-- -->6 0x00007fff734b4c50
clang++: error: unable to execute command: Segmentation fault
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 18.1.3 (1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/test-7765b2.cpp
clang++: note: diagnostic msg: /tmp/test-7765b2.sh
clang++: note: diagnostic msg:
********************
A live demo is in Compiler Explorer.
A zip with original c++ file, preprocessed file and run script is in test.zip
Further reduced: https://godbolt.org/z/jqeTKzqf4
template <int...>
struct int_sequence {};
int main() {
[]<int... i>(int_sequence<i...>) {
(
[](auto x = i) {
using lambda_type = decltype([] {return decltype(x){};});
decltype(&lambda_type::operator()){};
}(0),
...
);
}(int_sequence<0>{});
}
Fixed in trunk: https://godbolt.org/z/rbj1oMnnK