Issue |
153493
|
Summary |
[clang] Crash in lambda return type involving decltype of bound argument
|
Labels |
clang
|
Assignees |
|
Reporter |
MR2K5
|
The bug happens only when the lambda uses an explicit this parameter, and only when the `decltype` includes `+ 0` . The presence or absence of consteval has no effect,.
The bug is present in clang 19.1.0, but not in 18.1.0, which compiles succesfully.
Actually, both gcc and msvc fail to compile, saying that `bound` is not declared in scope.
### Reproducer:
[https://godbolt.org/z/eT3TM8soe]()
```
int main() {
auto lambda = [bound = 0](this auto&&) consteval -> decltype(bound + 0) {
return bound;
};
lambda();
}
```
### Backtrace:
```
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-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++26 <source>
1. <eof> parser at end of file
2. <source>:2:5: LLVM IR generation of declaration 'main'
3. <source>:2:5: Generating code for declaration 'main'
#0 0x0000000003cf8f48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cf8f48)
#1 0x0000000003cf691c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cf691c)
#2 0x0000000003c46c28 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007152b6c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00000000036b6c9a llvm::FunctionType::get(llvm::Type*, llvm::ArrayRef<llvm::Type*>, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x36b6c9a)
#5 0x00000000045454ab clang::CodeGen::CodeGenTypes::GetFunctionType(clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45454ab)
#6 0x00000000042cb128 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42cb128)
#7 0x000000000427883a clang::CodeGen::CodeGenModule::GetAddrOfFunction(clang::GlobalDecl, llvm::Type*, bool, bool, clang::CodeGen::ForDefinition_t) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x427883a)
#8 0x0000000004011f9c clang::CodeGen::CodeGenModule::getRawFunctionPointer(clang::GlobalDecl, llvm::Type*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4011f9c)
#9 0x00000000040189fa EmitDirectCallee(clang::CodeGen::CodeGenFunction&, clang::GlobalDecl) CGExpr.cpp:0:0
#10 0x000000000401ea4d clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x401ea4d)
#11 0x000000000401e81f clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x401e81f)
#12 0x00000000040316f7 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40316f7)
#13 0x00000000040a43d9 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#14 0x000000000409991c clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#15 0x000000000409bbbb (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#16 0x000000000409de5c (anonymous namespace)::ScalarExprEmitter::VisitConstantExpr(clang::ConstantExpr*) CGExprScalar.cpp:0:0
#17 0x000000000409a555 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#18 0x000000000409edd2 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x409edd2)
#19 0x000000000400b70e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x400b70e)
#20 0x000000000401c968 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x401c968)
#21 0x00000000041a0712 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x41a0712)
#22 0x00000000041a7c59 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x41a7c59)
#23 0x0000000004208f45 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4208f45)
#24 0x000000000421ca63 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x421ca63)
#25 0x0000000004278b8b clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4278b8b)
#26 0x0000000004274414 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4274414)
#27 0x0000000004274fe0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4274fe0)
#28 0x000000000427eaf7 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#29 0x0000000004643200 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#30 0x000000000462cf39 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x462cf39)
#31 0x00000000062bf194 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62bf194)
#32 0x000000000464039d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x464039d)
#33 0x000000000494c00a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x494c00a)
#34 0x00000000048c54bb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48c54bb)
#35 0x0000000004a3cc33 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4a3cc33)
#36 0x0000000000dc05c5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdc05c5)
#37 0x0000000000db856d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#38 0x00000000046b2699 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
#39 0x0000000003c47043 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c47043)
#40 0x00000000046b28b9 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
#41 0x0000000004675c4d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4675c4d)
#42 0x0000000004676c01 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4676c01)
#43 0x0000000004680a4c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4680a4c)
#44 0x0000000000dbcdd1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdbcdd1)
#45 0x0000000000c6bbe4 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc6bbe4)
#46 0x00007152b6c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#47 0x00007152b6c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#48 0x0000000000db8005 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdb8005)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs