llvm-project
llvm-project copied to clipboard
Parser crash when checking templated lambda type in concept
| Bugzilla Link | 52526 |
| Version | trunk |
| OS | Linux |
| Attachments | [tmp/main-38cf0d.cpp followed by https://user-images.githubusercontent.com/95090386/143762719-9b98ffc6-cd93-4dd2-a61e-d7ffe2bb932d.gz) |
Extended Description
The clang parser crashes on the following code :
///////////////////////////////////////////////////////////////////////////////
template<auto L>
concept C = requires {
typename decltype(L)::template operator()<int>;
};
template<auto L> requires C<L> struct S {};
auto x = S<[]<typename T>(T){}>;
https://godbolt.org/z/E9a6xx7Gs ///////////////////////////////////////////////////////////////////////////////
Backtrace:
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /usr/lib/llvm-13/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/neyl/Corrections/test -resource-dir /usr/lib/llvm-13/lib/clang/13.0.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /usr/lib/llvm-13/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/neyl/Corrections/test -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-7fc110.o -x c++ main.cpp
- main.cpp:9:10: at annotation token
#0 0x00007fe4d76fb183 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-13.so.1+0xbb9183)
#1 0x00007fe4d76f9500 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-13.so.1+0xbb7500)
#2 0x00007fe4d76fb61a (/lib/x86_64-linux-gnu/libLLVM-13.so.1+0xbb961a)
#3 0x00007fe4d6649520 (/lib/x86_64-linux-gnu/libc.so.6+0x46520)
#4 0x00007fe4dd22b842 clang::Selector::getAsStringabi:cxx11 const (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xb05842)
#5 0x00007fe4dd22b9a3 clang::Selector::print(llvm::raw_ostream&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xb059a3)
#6 0x00007fe4dd556d24 clang::DeclarationName::print(llvm::raw_ostream&, clang::PrintingPolicy const&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xe30d24)
#7 0x00007fe4dd557493 clang::operator<<(llvm::raw_ostream&, clang::DeclarationName) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xe31493)
#8 0x00007fe4dd40cc9d clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long> >, llvm::SmallVectorImpl
&, void*, llvm::ArrayRef ) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xce6c9d) #9 0x00007fe4dd213219 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl &) const (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xaed219) #10 0x00007fe4dda8b78c (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x136578c) #11 0x00007fe4ddf6a62e (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x184462e) #12 0x00007fe4ddf6278d (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x183c78d) #13 0x00007fe4ddf518af clang::Sema::SubstExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x182b8af) #14 0x00007fe4dda8b0a8 (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x13650a8) #15 0x00007fe4dda86293 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::ArrayRefclang::TemplateArgument, clang::SourceRange, clang::ConstraintSatisfaction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x1360293) #16 0x00007fe4dde8e842 clang::Sema::CheckConceptTemplateId(clang::CXXScopeSpec const&, clang::SourceLocation, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::ConceptDecl*, clang::TemplateArgumentListInfo const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x1768842) #17 0x00007fe4ddf5e158 (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x1838158) #18 0x00007fe4ddf518af clang::Sema::SubstExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x182b8af) #19 0x00007fe4dda8b0a8 (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x13650a8) #20 0x00007fe4dda86293 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::ArrayRefclang::TemplateArgument, clang::SourceRange, clang::ConstraintSatisfaction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x1360293) #21 0x00007fe4dda86e11 clang::Sema::EnsureTemplateArgumentListConstraints(clang::TemplateDecl*, llvm::ArrayRefclang::TemplateArgument, clang::SourceRange) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x1360e11) #22 0x00007fe4dde889cb clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImplclang::TemplateArgument&, bool, bool*) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x17629cb) #23 0x00007fe4dde86f04 clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x1760f04) #24 0x00007fe4dde89bfa clang::Sema::ActOnTemplateIdType(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::OpaquePtrclang::TemplateName, clang::IdentifierInfo*, clang::SourceLocation, clang::SourceLocation, llvm::MutableArrayRefclang::ParsedTemplateArgument, clang::SourceLocation, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x1763bfa) #25 0x00007fe4dd3b28c7 clang::Parser::AnnotateTemplateIdTokenAsType(clang::CXXScopeSpec&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc8c8c7) #26 0x00007fe4dd3c0c1c clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(clang::CXXScopeSpec&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc9ac1c) #27 0x00007fe4dd3c0fdf clang::Parser::TryAnnotateTypeOrScopeToken() (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc9afdf) #28 0x00007fe4dd3532e6 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc2d2e6) #29 0x00007fe4dd34d362 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc27362) #30 0x00007fe4dd3281ff clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc021ff) #31 0x00007fe4dd325cf6 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xbffcf6) #32 0x00007fe4dd3bdefd clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc97efd) #33 0x00007fe4dd3bd8dc clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc978dc) #34 0x00007fe4dd3bcdc1 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc96dc1) #35 0x00007fe4dd3bb430 clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xc95430) #36 0x00007fe4dd3115dd clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0xbeb5dd) #37 0x00007fe4dea57748 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x2331748) #38 0x00007fe4de9d8a56 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x22b2a56) #39 0x00007fe4deac5330 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.13+0x239f330) #40 0x0000000000412fc3 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-13/bin/clang+0x412fc3) #41 0x0000000000411055 (/usr/lib/llvm-13/bin/clang+0x411055) #42 0x0000000000410ed6 main (/usr/lib/llvm-13/bin/clang+0x410ed6) #43 0x00007fe4d6630fd0 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #44 0x00007fe4d663107d call_init ./csu/../csu/libc-start.c:128:20 #45 0x00007fe4d663107d __libc_start_main ./csu/../csu/libc-start.c:379:5 #46 0x000000000040e1c5 _start (/usr/lib/llvm-13/bin/clang+0x40e1c5) clang: error: unable to execute command: Segmentation fault (core dumped) clang: error: clang frontend command failed due to signal (use -v to see invocation) Ubuntu clang version 13.0.0-2 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/main-38cf0d.cpp clang: note: diagnostic msg: /tmp/main-38cf0d.sh clang: note: diagnostic msg:
@llvm/issue-subscribers-clang-frontend
@llvm/issue-subscribers-c-20
AFAICT the type requirement in the concept is a syntax error, as template operator() is not a valid identifier. MSVC and GCC accept, though.
Still crashing as of Clang 16: https://godbolt.org/z/65E544EcW
Assertion:
clang++: /root/llvm-project/clang/include/clang/AST/TemplateName.h:551:
const clang::IdentifierInfo* clang::DependentTemplateName::getIdentifier() const:
Assertion `isIdentifier() && "Template name isn't an identifier?"' failed.
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-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <source>:2:70: current parser token ';'
#0 0x0000563f0f0dbdbf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c12dbf)
#1 0x0000563f0f0d9b2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c10b2c)
#2 0x0000563f0f0231a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007feb9612c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007feb95bf900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007feb95bd8859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007feb95bd8729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007feb95be9fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000563f121ee682 clang::Sema::ActOnTypenameType(clang::Scope*, clang::SourceLocation, clang::CXXScopeSpec const&, clang::SourceLocation, clang::OpaquePtr<clang::TemplateName>, clang::IdentifierInfo*, clang::SourceLocation, clang::SourceLocation, llvm::MutableArrayRef<clang::ParsedTemplateArgument>, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d25682)
#9 0x0000563f11e7e14d clang::Sema::ActOnTypeRequirement(clang::SourceLocation, clang::CXXScopeSpec&, clang::SourceLocation, clang::IdentifierInfo*, clang::TemplateIdAnnotation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69b514d)
#10 0x0000563f118a0bf4 clang::Parser::ParseRequiresExpression() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63d7bf4)
#11 0x0000563f1188cd61 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63c3d61)
#12 0x0000563f1189a29a clang::Parser::ParseConstraintExpression() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63d129a)
#13 0x0000563f119216c7 clang::Parser::ParseConceptDefinition(clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64586c7)
#14 0x0000563f1192b000 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#15 0x0000563f1192b1e3 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64621e3)
#16 0x0000563f11865702 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x639c702)
#17 0x0000563f11830954 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6367954)
#18 0x0000563f11831896 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6368896)
#19 0x0000563f11831d34 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6368d34)
#20 0x0000563f1182562a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x635c62a)
#21 0x0000563f103297c8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e607c8)
#22 0x0000563f0fb80f09 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46b7f09)
#23 0x0000563f0fb053d6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x463c3d6)
#24 0x0000563f0fc639e6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479a9e6)
#25 0x0000563f0c59746d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10ce46d)
#26 0x0000563f0c59316a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000563f0f96d39d 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
#28 0x0000563f0f0236b0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b5a6b0)
#29 0x0000563f0f96d9bf 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
#30 0x0000563f0f9350ec clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446c0ec)
#31 0x0000563f0f935b7d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446cb7d)
#32 0x0000563f0f93dc5d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4474c5d)
#33 0x0000563f0c5956ca clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10cc6ca)
#34 0x0000563f0c49c235 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xfd3235)
#35 0x00007feb95bda083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#36 0x0000563f0c58df4e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10c4f4e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134