-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Capturing structured binding in lambda in module causes Assertion isa<X>(Val) && "cast_if_present<Ty>() argument of incompatible type!"
#72828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:modules
C++20 modules and Clang Header Modules
confirmed
Verified by a second party
crash
Prefer [crash-on-valid] or [crash-on-invalid]
Comments
@llvm/issue-subscribers-clang-frontend Author: David Stone (davidstone)
The following valid translation unit:
export module m;
struct s {
int m;
};
void f() {
auto [x] = s();
[x] {};
} causes clang to crash with clang-18: /root/llvm-project/llvm/include/llvm/Support/Casting.h:706: auto llvm::cast_if_present(Y*) [with X = clang::VarDecl; Y = clang::Decl]: Assertion `isa<X>(Val) && "cast_if_present<Ty>() argument of incompatible type!"' failed.
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-20231120/bin/clang-18 -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -main-file-name example.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 -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20231120/lib/clang/18 -w -std=c++20 -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /app/output.s -x pcm /tmp/example-e4405b.pcm
1. <eof> parser at end of file
2. <source>:7:6: LLVM IR generation of declaration 'f'
3. <source>:7:6: Generating code for declaration 'f'
#<!-- -->0 0x0000000003795218 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3795218)
#<!-- -->1 0x000000000379296c SignalHandler(int) Signals.cpp:0:0
#<!-- -->2 0x00007fbb303d2420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#<!-- -->3 0x00007fbb2fe9500b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#<!-- -->4 0x00007fbb2fe74859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#<!-- -->5 0x00007fbb2fe74729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#<!-- -->6 0x00007fbb2fe85fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#<!-- -->7 0x00000000044018d3 clang::ASTDeclReader::ReadCXXDefinitionData(clang::CXXRecordDecl::DefinitionData&, clang::CXXRecordDecl const*, clang::Decl*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x44018d3)
#<!-- -->8 0x000000000440e9b8 clang::ASTDeclReader::ReadCXXRecordDefinition(clang::CXXRecordDecl*, bool, clang::Decl*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x440e9b8)
#<!-- -->9 0x000000000442174b clang::ASTDeclReader::VisitCXXRecordDeclImpl(clang::CXXRecordDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x442174b)
#<!-- -->10 0x0000000004427b65 clang::declvisitor::Base<std::add_pointer, clang::ASTDeclReader, void>::Visit(clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4427b65)
#<!-- -->11 0x0000000004428022 clang::ASTDeclReader::Visit(clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4428022)
#<!-- -->12 0x0000000004428679 clang::ASTReader::ReadDeclRecord(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4428679)
#<!-- -->13 0x000000000435dc1b clang::ASTReader::GetDecl(unsigned int) (.part.0) ASTReader.cpp:0:0
#<!-- -->14 0x00000000043c8bb7 clang::serialization::AbstractTypeReader<clang::ASTRecordReader>::read(clang::Type::TypeClass) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43c8bb7)
#<!-- -->15 0x00000000043c9df9 clang::ASTReader::readTypeRecord(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43c9df9)
#<!-- -->16 0x00000000043ca304 clang::ASTReader::GetType(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43ca304)
#<!-- -->17 0x000000000442c3fb clang::ASTStmtReader::VisitExpr(clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x442c3fb)
#<!-- -->18 0x0000000004434971 clang::ASTStmtReader::VisitLambdaExpr(clang::LambdaExpr*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4434971)
#<!-- -->19 0x000000000443c0f2 clang::ASTReader::ReadStmtFromStream(clang::serialization::ModuleFile&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x443c0f2)
#<!-- -->20 0x0000000004381c64 clang::ASTReader::GetExternalDeclStmt(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4381c64)
#<!-- -->21 0x0000000006f9b783 clang::FunctionDecl::getBody(clang::FunctionDecl const*&) const (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x6f9b783)
#<!-- -->22 0x0000000003b2b669 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b2b669)
#<!-- -->23 0x0000000003b8cc53 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b8cc53)
#<!-- -->24 0x0000000003b87ae5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b87ae5)
#<!-- -->25 0x0000000003b880d3 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b880d3)
#<!-- -->26 0x0000000003b91753 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#<!-- -->27 0x0000000004010d86 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#<!-- -->28 0x0000000004002e6c clang::BackendConsumer::HandleInterestingDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4002e6c)
#<!-- -->29 0x00000000043e42fd clang::ASTReader::PassInterestingDeclsToConsumer() (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43e42fd)
#<!-- -->30 0x0000000004355fae non-virtual thunk to clang::ASTReader::StartTranslationUnit(clang::ASTConsumer*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4355fae)
#<!-- -->31 0x0000000005f1ed08 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x5f1ed08)
#<!-- -->32 0x000000000400e9a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x400e9a8)
#<!-- -->33 0x0000000004275209 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4275209)
#<!-- -->34 0x00000000041f56de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x41f56de)
#<!-- -->35 0x000000000435454e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x435454e)
#<!-- -->36 0x0000000000bf8346 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xbf8346)
#<!-- -->37 0x0000000000befc0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#<!-- -->38 0x0000000000bf47aa clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xbf47aa)
#<!-- -->39 0x0000000000aef061 main (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xaef061)
#<!-- -->40 0x00007fbb2fe76083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#<!-- -->41 0x0000000000bef6ee _start (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xbef6ee)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 254 when compiled with See it live: https://godbolt.org/z/KqsWGqdsY |
CC @ChuanqiXu9 |
Confirmed |
@llvm/issue-subscribers-clang-modules Author: David Stone (davidstone)
The following valid translation unit:
export module m;
struct s {
int m;
};
void f() {
auto [x] = s();
[x] {};
} causes clang to crash with clang-18: /root/llvm-project/llvm/include/llvm/Support/Casting.h:706: auto llvm::cast_if_present(Y*) [with X = clang::VarDecl; Y = clang::Decl]: Assertion `isa<X>(Val) && "cast_if_present<Ty>() argument of incompatible type!"' failed.
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-20231120/bin/clang-18 -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -main-file-name example.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 -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20231120/lib/clang/18 -w -std=c++20 -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /app/output.s -x pcm /tmp/example-e4405b.pcm
1. <eof> parser at end of file
2. <source>:7:6: LLVM IR generation of declaration 'f'
3. <source>:7:6: Generating code for declaration 'f'
#<!-- -->0 0x0000000003795218 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3795218)
#<!-- -->1 0x000000000379296c SignalHandler(int) Signals.cpp:0:0
#<!-- -->2 0x00007fbb303d2420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#<!-- -->3 0x00007fbb2fe9500b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#<!-- -->4 0x00007fbb2fe74859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#<!-- -->5 0x00007fbb2fe74729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#<!-- -->6 0x00007fbb2fe85fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#<!-- -->7 0x00000000044018d3 clang::ASTDeclReader::ReadCXXDefinitionData(clang::CXXRecordDecl::DefinitionData&, clang::CXXRecordDecl const*, clang::Decl*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x44018d3)
#<!-- -->8 0x000000000440e9b8 clang::ASTDeclReader::ReadCXXRecordDefinition(clang::CXXRecordDecl*, bool, clang::Decl*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x440e9b8)
#<!-- -->9 0x000000000442174b clang::ASTDeclReader::VisitCXXRecordDeclImpl(clang::CXXRecordDecl*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x442174b)
#<!-- -->10 0x0000000004427b65 clang::declvisitor::Base<std::add_pointer, clang::ASTDeclReader, void>::Visit(clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4427b65)
#<!-- -->11 0x0000000004428022 clang::ASTDeclReader::Visit(clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4428022)
#<!-- -->12 0x0000000004428679 clang::ASTReader::ReadDeclRecord(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4428679)
#<!-- -->13 0x000000000435dc1b clang::ASTReader::GetDecl(unsigned int) (.part.0) ASTReader.cpp:0:0
#<!-- -->14 0x00000000043c8bb7 clang::serialization::AbstractTypeReader<clang::ASTRecordReader>::read(clang::Type::TypeClass) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43c8bb7)
#<!-- -->15 0x00000000043c9df9 clang::ASTReader::readTypeRecord(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43c9df9)
#<!-- -->16 0x00000000043ca304 clang::ASTReader::GetType(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43ca304)
#<!-- -->17 0x000000000442c3fb clang::ASTStmtReader::VisitExpr(clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x442c3fb)
#<!-- -->18 0x0000000004434971 clang::ASTStmtReader::VisitLambdaExpr(clang::LambdaExpr*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4434971)
#<!-- -->19 0x000000000443c0f2 clang::ASTReader::ReadStmtFromStream(clang::serialization::ModuleFile&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x443c0f2)
#<!-- -->20 0x0000000004381c64 clang::ASTReader::GetExternalDeclStmt(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4381c64)
#<!-- -->21 0x0000000006f9b783 clang::FunctionDecl::getBody(clang::FunctionDecl const*&) const (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x6f9b783)
#<!-- -->22 0x0000000003b2b669 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b2b669)
#<!-- -->23 0x0000000003b8cc53 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b8cc53)
#<!-- -->24 0x0000000003b87ae5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b87ae5)
#<!-- -->25 0x0000000003b880d3 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x3b880d3)
#<!-- -->26 0x0000000003b91753 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#<!-- -->27 0x0000000004010d86 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#<!-- -->28 0x0000000004002e6c clang::BackendConsumer::HandleInterestingDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4002e6c)
#<!-- -->29 0x00000000043e42fd clang::ASTReader::PassInterestingDeclsToConsumer() (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x43e42fd)
#<!-- -->30 0x0000000004355fae non-virtual thunk to clang::ASTReader::StartTranslationUnit(clang::ASTConsumer*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4355fae)
#<!-- -->31 0x0000000005f1ed08 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x5f1ed08)
#<!-- -->32 0x000000000400e9a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x400e9a8)
#<!-- -->33 0x0000000004275209 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x4275209)
#<!-- -->34 0x00000000041f56de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x41f56de)
#<!-- -->35 0x000000000435454e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0x435454e)
#<!-- -->36 0x0000000000bf8346 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xbf8346)
#<!-- -->37 0x0000000000befc0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#<!-- -->38 0x0000000000bf47aa clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xbf47aa)
#<!-- -->39 0x0000000000aef061 main (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xaef061)
#<!-- -->40 0x00007fbb2fe76083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#<!-- -->41 0x0000000000bef6ee _start (/opt/compiler-explorer/clang-assertions-trunk-20231120/bin/clang-18+0xbef6ee)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 254 when compiled with See it live: https://godbolt.org/z/KqsWGqdsY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:modules
C++20 modules and Clang Header Modules
confirmed
Verified by a second party
crash
Prefer [crash-on-valid] or [crash-on-invalid]
Uh oh!
There was an error while loading. Please reload this page.
The following valid translation unit:
causes clang to crash with
when compiled with
-std=c++20 -w -x c++-module
See it live: https://godbolt.org/z/KqsWGqdsY
The text was updated successfully, but these errors were encountered: