llvm / llvm/llvm-project

[clang] Assertion `isa<X>(Val) && "cast_if_present<Ty>() argument of incompatible type!"' failed.

Open
#198,762 3 comments 0 reactions 0 assignees View on GitHub
clang:frontend crash generated by fuzzer regression:22
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/rPPM9ea5K
```cpp
template concept C> struct S {
template C auto> void bar();
};
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/include/llvm/Support/Casting.h:700: auto llvm::cast_if_present(Y*) [with X = clang::ConceptDecl; Y = clang::Decl]: Assertion `isa(Val) && "cast_if_present() 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/bin/clang++ -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++2c
1. :2:43: current parser token ';'
2. :1:45: parsing struct/union/class body 'S'
#0 0x000000000453f658 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453f658)
#1 0x000000000453c484 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453c484)
#2 0x000000000453caa4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453caa4)
#3 0x0000000004479268 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007823c2a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007823c2a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x00007823c2a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x00007823c2a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x00007823c2a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x00007823c2a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x00000000079168a2 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x79168a2)
#11 0x00000000078fc8e9 clang::TreeTransform<(anonymous namespace)::CurrentInstantiationRebuilder>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplate.cpp:0:0
#12 0x00000000078fb42b clang::QualType clang::TreeTransform<(anonymous namespace)::CurrentInstantiationRebuilder>::TransformFunctionProtoType::TransformFunctionProtoType(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc)::'lambda'(clang::FunctionProtoType::ExceptionSpecInfo&, bool&)>(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc, clang::CXXRecordDecl*, clang::Qualifiers, clang::TreeTransform<(anonymous namespace)::CurrentInstantiationRebuilder>::TransformFunctionProtoType(clang::TypeLocBuilder&, clang::FunctionProtoTypeLoc)::'lambda'(clang::FunctionProtoType::ExceptionSpecInfo&, bool&)) (.constprop.0) SemaTemplate.cpp:0:0
#13 0x00000000078fcbb2 clang::TreeTransform<(anonymous namespace)::CurrentInstantiationRebuilder>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplate.cpp:0:0
#14 0x00000000078fdd2a clang::TreeTransform<(anonymous namespace)::CurrentInstantiationRebuilder>::TransformType(clang::TypeSourceInfo*) SemaTemplate.cpp:0:0
#15 0x00000000078fde60 clang::Sema::RebuildTypeInCurrentInstantiation(clang::TypeSourceInfo*, clang::SourceLocation, clang::DeclarationName) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x78fde60)
#16 0x00000000078fdfa2 clang::Sema::RebuildTemplateParamsInCurrentInstantiation(clang::TemplateParameterList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x78fdfa2)
#17 0x000000000729b6f6 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x729b6f6)
#18 0x000000000729d64b clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x729d64b)
#19 0x000000000734362f clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier, clang::Declarator&, llvm::MutableArrayRef, clang::Expr*, clang::VirtSpecifiers const&, clang::InClassInitStyle) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x734362f)
#20 0x0000000006f0369e clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f0369e)
#21 0x0000000006fabf73 clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fabf73)
#22 0x0000000006fb90a9 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#23 0x0000000006f02cf5 clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f02cf5)
#24 0x0000000006f04d9f clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&, clang::ParsedAttributes&, clang::TypeSpecifierType, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f04d9f)
#25 0x0000000006f06a7f clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f06a7f)
#26 0x0000000006f0941b clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f0941b)
#27 0x0000000006edcabc clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6edcabc)
#28 0x0000000006fabb79 clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fabb79)
#29 0x0000000006fb90a9 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#30 0x0000000006fb94ba clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fb94ba)
#31 0x0000000006ee3a40 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ee3a40)
#32 0x0000000006e9f976 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9f976)
#33 0x0000000006ea0865 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea0865)
#34 0x0000000006ea0c50 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea0c50)
#35 0x0000000006e81713 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e81713)
#36 0x00000000050577f8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x50577f8)
#37 0x000000000537f275 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x537f275)
#38 0x00000000052fddf8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52fddf8)
#39 0x000000000547bb4d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x547bb4d)
#40 0x0000000000df703b cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf703b)
#41 0x0000000000ded99a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#42 0x0000000000dedb1d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#43 0x00000000050c7189 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#44 0x00000000044796a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44796a4)
#45 0x00000000050c77b6 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#46 0x0000000005085e92 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5085e92)
#47 0x0000000005086e3e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5086e3e)
#48 0x000000000508eae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x508eae5)
#49 0x0000000000df33c4 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf33c4)
#50 0x0000000000caa03a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcaa03a)
#51 0x00007823c2a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#52 0x00007823c2a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#53 0x0000000000ded435 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xded435)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.