clang13 parser crashes for invalid code when template function return type is "auto" #53851
Labels
c++20
clang:codegen
confirmed
Verified by a second party
crash
Prefer [crash-on-valid] or [crash-on-invalid]
clang13 crashes with exit code 139 for following invalid template id
foo<int>
. See compiler explorer. Interestingly, changing return type from auto to void would prevent crash from happening. My guess is that no return code in function body should enable "return-type-deduction" to assign void to auto, isn't it?#0 0x0000556c70adf35f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x0000556c70add220 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x34dd220)
#2 0x0000556c70a2e218 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fa20e9b03c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00007fa20e5c771d (/lib/x86_64-linux-gnu/libc.so.6+0x18e71d)
#5 0x0000556c6e88306a llvm::raw_ostream::operator<<(char const*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x128306a)
#6 0x0000556c7357511c (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) ItaniumMangle.cpp:0:0
#7 0x0000556c7356cf91 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) ItaniumMangle.cpp:0:0
#8 0x0000556c7357215c (anonymous namespace)::CXXNameMangler::mangleBareFunctionType(clang::FunctionProtoType const*, bool, clang::FunctionDecl const*) ItaniumMangle.cpp:0:0
#9 0x0000556c73577432 (anonymous namespace)::CXXNameMangler::mangleFunctionEncoding(clang::GlobalDecl) ItaniumMangle.cpp:0:0
#10 0x0000556c73578f77 (anonymous namespace)::ItaniumMangleContextImpl::mangleCXXName(clang::GlobalDecl, llvm::raw_ostream&) ItaniumMangle.cpp:0:0
#11 0x0000556c70e8416a getMangledNameImpl(clang::CodeGen::CodeGenModule&, clang::GlobalDecl, clang::NamedDecl const*, bool) CodeGenModule.cpp:0:0
#12 0x0000556c70e91fb5 clang::CodeGen::CodeGenModule::getMangledName(clang::GlobalDecl) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3891fb5)
#13 0x0000556c70eb9529 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x38b9529)
#14 0x0000556c70ebf671 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5272) CodeGenModule.cpp:0:0
#15 0x0000556c71a35f11 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#16 0x0000556c71a29d52 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x4429d52)
#17 0x0000556c730bb163 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x5abb163)
#18 0x0000556c7299cc9f clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x539cc9f)
#19 0x0000556c72ff513d clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x59f513d)
#20 0x0000556c7302729b clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x5a2729b)
#21 0x0000556c73027307 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x5a27307)
#22 0x0000556c72ee5c65 clang::Sema::ResolveSingleFunctionTemplateSpecialization(clang::OverloadExpr*, bool, clang::DeclAccessPair*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x58e5c65)
#23 0x0000556c72ee6354 clang::Sema::ResolveAndFixSingleFunctionTemplateSpecialization(clang::ActionResult<clang::Expr*, true>&, bool, bool, clang::SourceRange, clang::QualType, unsigned int) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x58e6354)
#24 0x0000556c72c26e6d clang::Sema::CheckPlaceholderExpr(clang::Expr*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x5626e6d)
#25 0x0000556c72d2d1d4 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x572d1d4)
#26 0x0000556c72f1b114 clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x591b114)
#27 0x0000556c729474a3 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x53474a3)
#28 0x0000556c7293fd7b clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributesWithRange&) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x533fd7b)
#29 0x0000556c72940cbd clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x5340cbd)
#30 0x0000556c7293b862 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x533b862)
#31 0x0000556c7293c693 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x533c693)
#32 0x0000556c728967c4 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x52967c4)
#33 0x0000556c728bf7c1 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x52bf7c1)
#34 0x0000556c72891859 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x5291859)
#35 0x0000556c72891f61 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.280) Parser.cpp:0:0
#36 0x0000556c72897e89 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x5297e89)
#37 0x0000556c728992a9 clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x52992a9)
#38 0x0000556c7288cb09 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x528cb09)
#39 0x0000556c71a33e22 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x4433e22)
#40 0x0000556c713e0ff1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3de0ff1)
#41 0x0000556c7137f2b2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3d7f2b2)
#42 0x0000556c714ad733 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3ead733)
#43 0x0000556c6e88611c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x128611c)
#44 0x0000556c6e8822fd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#45 0x0000556c7122a605 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::'lambda'()>(long) Job.cpp:0:0
#46 0x0000556c70a2e803 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x342e803)
#47 0x0000556c7122c6be clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3c2c6be)
#48 0x0000556c712020ea clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3c020ea)
#49 0x0000556c71202c3f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3c02c3f)
#50 0x0000556c7120c035 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x3c0c035)
#51 0x0000556c6e79b56e main (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x119b56e)
#52 0x00007fa20e4600b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#53 0x0000556c6e881e7a _start (/opt/compiler-explorer/clang-13.0.1/bin/clang+++0x1281e7a)
clang-13: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
The text was updated successfully, but these errors were encountered: