llvm-project
llvm-project copied to clipboard
[clang] Assertion `!Params->empty() && "template with no template parameters"' failed.
This seems a recent regression (not reproducible with clang-22).
Reproducer: https://godbolt.org/z/4MjPz6znE
template <> template <typename T> using Foo = T;
Backtrace:
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/DeclTemplate.cpp:1265: static clang::TypeAliasTemplateDecl* clang::TypeAliasTemplateDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::DeclarationName, clang::TemplateParameterList*, clang::NamedDecl*): Assertion `!Params->empty() && "template with no template parameters"' 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 <source>
1. <eof> parser at end of file
#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 0x00007a2f6c242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007a2f6c2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x00007a2f6c242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x00007a2f6c2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x00007a2f6c22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x00007a2f6c239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x0000000008100bcc (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8100bcc)
#11 0x000000000731c65c clang::Sema::ActOnAliasDeclaration(clang::Scope*, clang::AccessSpecifier, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SourceLocation, clang::UnqualifiedId&, clang::ParsedAttributesView const&, clang::ActionResult<clang::OpaquePtr<clang::QualType>, false>, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x731c65c)
#12 0x0000000006ef5022 clang::Parser::ParseAliasDeclarationAfterDeclarator(clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::Parser::UsingDeclarator&, clang::SourceLocation&, clang::AccessSpecifier, clang::ParsedAttributes&, clang::Decl**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ef5022)
#13 0x0000000006efc56a clang::Parser::ParseUsingDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6efc56a)
#14 0x0000000006efd125 clang::Parser::ParseUsingDirectiveOrDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6efd125)
#15 0x0000000006fababa clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fababa)
#16 0x0000000006fb90a9 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#17 0x0000000006fb94ba clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fb94ba)
#18 0x0000000006ee3a40 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ee3a40)
#19 0x0000000006e9f976 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9f976)
#20 0x0000000006ea0865 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea0865)
#21 0x0000000006ea0c50 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea0c50)
#22 0x0000000006e81713 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e81713)
#23 0x00000000050577f8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x50577f8)
#24 0x000000000537f275 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x537f275)
#25 0x00000000052fddf8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52fddf8)
#26 0x000000000547bb4d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x547bb4d)
#27 0x0000000000df703b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf703b)
#28 0x0000000000ded99a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#29 0x0000000000dedb1d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#30 0x00000000050c7189 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
#31 0x00000000044796a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44796a4)
#32 0x00000000050c77b6 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
#33 0x0000000005085e92 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5085e92)
#34 0x0000000005086e3e 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+++0x5086e3e)
#35 0x000000000508eae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x508eae5)
#36 0x0000000000df33c4 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf33c4)
#37 0x0000000000caa03a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcaa03a)
#38 0x00007a2f6c229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x00007a2f6c229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 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
@llvm/issue-subscribers-clang-frontend
Author: k-arrows
This seems a reccent regression (not reproducible with clang-22).
Reproducer: https://godbolt.org/z/4MjPz6znE
template <> template <typename T> using Foo = T;
Backtrace:
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/DeclTemplate.cpp:1265: static clang::TypeAliasTemplateDecl* clang::TypeAliasTemplateDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::DeclarationName, clang::TemplateParameterList*, clang::NamedDecl*): Assertion `!Params->empty() && "template with no template parameters"' 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 <source>
1. <eof> parser at end of file
#<!-- -->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 0x00007a2f6c242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#<!-- -->5 0x00007a2f6c2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#<!-- -->6 0x00007a2f6c242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#<!-- -->7 0x00007a2f6c2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#<!-- -->8 0x00007a2f6c22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#<!-- -->9 0x00007a2f6c239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#<!-- -->10 0x0000000008100bcc (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8100bcc)
#<!-- -->11 0x000000000731c65c clang::Sema::ActOnAliasDeclaration(clang::Scope*, clang::AccessSpecifier, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SourceLocation, clang::UnqualifiedId&, clang::ParsedAttributesView const&, clang::ActionResult<clang::OpaquePtr<clang::QualType>, false>, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x731c65c)
#<!-- -->12 0x0000000006ef5022 clang::Parser::ParseAliasDeclarationAfterDeclarator(clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::Parser::UsingDeclarator&, clang::SourceLocation&, clang::AccessSpecifier, clang::ParsedAttributes&, clang::Decl**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ef5022)
#<!-- -->13 0x0000000006efc56a clang::Parser::ParseUsingDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6efc56a)
#<!-- -->14 0x0000000006efd125 clang::Parser::ParseUsingDirectiveOrDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6efd125)
#<!-- -->15 0x0000000006fababa clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fababa)
#<!-- -->16 0x0000000006fb90a9 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#<!-- -->17 0x0000000006fb94ba clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fb94ba)
#<!-- -->18 0x0000000006ee3a40 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ee3a40)
#<!-- -->19 0x0000000006e9f976 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9f976)
#<!-- -->20 0x0000000006ea0865 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea0865)
#<!-- -->21 0x0000000006ea0c50 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea0c50)
#<!-- -->22 0x0000000006e81713 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e81713)
#<!-- -->23 0x00000000050577f8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x50577f8)
#<!-- -->24 0x000000000537f275 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x537f275)
#<!-- -->25 0x00000000052fddf8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52fddf8)
#<!-- -->26 0x000000000547bb4d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x547bb4d)
#<!-- -->27 0x0000000000df703b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf703b)
#<!-- -->28 0x0000000000ded99a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#<!-- -->29 0x0000000000dedb1d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#<!-- -->30 0x00000000050c7189 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
#<!-- -->31 0x00000000044796a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44796a4)
#<!-- -->32 0x00000000050c77b6 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
#<!-- -->33 0x0000000005085e92 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5085e92)
#<!-- -->34 0x0000000005086e3e 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+++0x5086e3e)
#<!-- -->35 0x000000000508eae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x508eae5)
#<!-- -->36 0x0000000000df33c4 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf33c4)
#<!-- -->37 0x0000000000caa03a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcaa03a)
#<!-- -->38 0x00007a2f6c229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->39 0x00007a2f6c229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->40 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
Bisects to fd51c78 @mizvekov .