[clang] Assertion `T::isKind(*this)' failed when invoking an inherited constructor with [[gnu::stdcall]] attribute
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer:
https://godbolt.org/z/zc67bq5n5
```cpp
struct S {
[[gnu::stdcall]] S(int);
};
struct SS : S {
using S::S;
void foo() { SS(42); }
};
```
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/include/clang/AST/TypeLoc.h:79: T clang::TypeLoc::castAs() const [with T = clang::FunctionProtoTypeLoc]: Assertion `T::isKind(*this)' 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
1. :7:22: current parser token ';'
2. :5:1: parsing struct/union/class body 'SS'
3. :7:14: parsing function body 'SS::foo'
4. :7:14: in compound statement ('{}')
#0 0x000000000435f348 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x435f348)
#1 0x000000000435c184 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x435c184)
#2 0x000000000435c7a4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x435c7a4)
#3 0x000000000429aa98 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007a8033842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007a80338969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x00007a8033842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x00007a80338287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x00007a803382871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x00007a8033839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x00000000070ff8af clang::Sema::findInheritingConstructor(clang::SourceLocation, clang::CXXConstructorDecl*, clang::ConstructorUsingShadowDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70ff8af)
#11 0x0000000007102c14 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::NamedDecl*, clang::CXXConstructorDecl*, llvm::MutableArrayRef, bool, bool, bool, bool, clang::CXXConstructionKind, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7102c14)
#12 0x0000000007310599 PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#13 0x000000000731b871 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x731b871)
#14 0x0000000006e58d90 TryStaticImplicitCast(clang::Sema&, clang::ActionResult&, clang::QualType, clang::CheckedConversionKind, (anonymous namespace)::CastOperation::OpRangeType, unsigned int&, clang::CastKind&, bool) SemaCast.cpp:0:0
#15 0x0000000006e5eba5 TryStaticCast(clang::Sema&, clang::ActionResult&, clang::QualType, clang::CheckedConversionKind, (anonymous namespace)::CastOperation::OpRangeType, unsigned int&, clang::CastKind&, llvm::SmallVector&, bool) SemaCast.cpp:0:0
#16 0x0000000006e663a2 (anonymous namespace)::CastOperation::CheckCXXCStyleCast(bool, bool) SemaCast.cpp:0:0
#17 0x0000000006e666a4 clang::Sema::BuildCXXFunctionalCastExpr(clang::TypeSourceInfo*, clang::QualType, clang::SourceLocation, clang::Expr*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e666a4)
#18 0x000000000727724f clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x727724f)
#19 0x0000000007277d09 clang::Sema::ActOnCXXTypeConstructExpr(clang::OpaquePtr, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7277d09)
#20 0x0000000006cda905 clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cda905)
#21 0x0000000006cbf28b clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cbf28b)
#22 0x0000000006cbfde7 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cbfde7)
#23 0x0000000006cbfe79 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cbfe79)
#24 0x0000000006cc44b9 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cc44b9)
#25 0x0000000006d4bc09 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4bc09)
#26 0x0000000006d43184 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d43184)
#27 0x0000000006d43b69 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d43b69)
#28 0x0000000006d4c38e clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4c38e)
#29 0x0000000006d4cbaa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4cbaa)
#30 0x0000000006c5f580 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c5f580)
#31 0x0000000006c5f26d clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c5f26d)
#32 0x0000000006cb3b56 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cb3b56)
#33 0x0000000006cb641b 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+++0x6cb641b)
#34 0x0000000006c89a7c 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+++0x6c89a7c)
#35 0x0000000006c43e97 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c43e97)
#36 0x0000000006c4491f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4491f)
#37 0x0000000006c4c3e1 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4c3e1)
#38 0x0000000006c4d315 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4d315)
#39 0x0000000006c2e1ba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c2e1ba)
#40 0x0000000004e576a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e576a8)
#41 0x00000000051881b8 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51881b8)
#42 0x00000000051075d0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51075d0)
#43 0x0000000005285cfd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5285cfd)
#44 0x0000000000e13adb cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe13adb)
#45 0x0000000000e0a48a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#46 0x0000000000e0a60d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#47 0x0000000004ec8919 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#48 0x000000000429aed4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x429aed4)
#49 0x0000000004ec8f66 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#50 0x0000000004e86f92 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e86f92)
#51 0x0000000004e87f3e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e87f3e)
#52 0x0000000004e8fb65 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e8fb65)
#53 0x0000000000e0feb4 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe0feb4)
#54 0x0000000000cb2d5a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb2d5a)
#55 0x00007a8033829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#56 0x00007a8033829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#57 0x0000000000e09f25 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe09f25)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
Contributor guide
Assessment
This issue has not been assessed yet.