llvm / llvm/llvm-project

[clang] Assertion `(Qualifier || TPLs.empty()) && "template parameter lists without qualifier"' failed.

Open
#207,911 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clang:frontend crash-on-invalid generated by fuzzer regression:23
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Although it does not reproduce on Godbolt, the following reproducer triggers an assertion failure with the clang I built today.

Reproducer:

template <typename> struct S {
  template <typename typename> inline auto foo = 42;
};

int bar = S<int>::foo<int, int>;

Backtrace:

 #0 0x0000756ef89d3e0a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
 #1 0x0000756ef89d0c6e llvm::sys::RunSignalHandlers() 
 #2 0x0000756ef89d298e llvm::sys::CleanupOnSignal(unsigned long) 
 #3 0x0000756ef88e6878 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x0000756ef8042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x0000756ef80969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x0000756ef80969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x0000756ef80969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x0000756ef8042476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x0000756ef80287f3 abort ./stdlib/abort.c:81:7
#10 0x0000756ef802871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x0000756ef8039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#12 0x0000756ef5597ab2 clang::Sema::getTemplateInstantiationArgs(clang::Decl const*, std::optional<llvm::ArrayRef<clang::TemplateArgument>>, clang::OptionalUnsigned<unsigned int>, bool) 
#13 0x0000756ef566923a clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, clang::VarDecl*, bool, bool, bool) 
#14 0x0000756ef566a792 clang::Sema::PerformPendingInstantiations(bool, bool) 
#15 0x0000756ef4d12968 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::TUFragmentKind) 
#16 0x0000756ef4d132d6 clang::Sema::ActOnEndOfTranslationUnit() 
#17 0x0000756ef83a3be4 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) 
#18 0x0000756ef82a8b0e clang::ParseAST(clang::Sema&, bool, bool) 
#19 0x0000756efb360de6 clang::FrontendAction::Execute() 
#20 0x0000756efb2ce328 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
#21 0x0000756efeecf8c5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
#22 0x000063fba3c77e86 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
#23 0x000063fba3c73f36 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#24 0x000063fba3c76359 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_2>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#25 0x0000756efb6bfe19 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::$_1>(long) Job.cpp:0:0
#26 0x0000756ef88e658b llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) 
#27 0x0000756efb6bf113 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const 
#28 0x0000756efb670a63 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const 
#29 0x0000756efb670d57 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const 
#30 0x0000756efb699ce8 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) 
#31 0x000063fba3c73551 clang_main(int, char**, llvm::ToolContext const&) 
#32 0x000063fba3c8360d main 
#33 0x0000756ef8029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#34 0x0000756ef8029e40 call_init ./csu/../csu/libc-start.c:128:20
#35 0x0000756ef8029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#36 0x000063fba3c718c5 _start 
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 23.0.0git (https://github.com/llvm/llvm-project.git 06f4b027b2df1febf3cd496573b8739074e8aa29)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Assertion failure:

llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:251: clang::MultiLevelTemplateArgumentList clang::Sema::getTemplateInstantiationArgs(const clang::Decl *, std::optional<ArrayRef<TemplateArgument>>, clang::UnsignedOrNone, bool): Assertion `(Qualifier || TPLs.empty()) && "template parameter lists without qualifier"' failed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided C++ reproducer with Clang and reading getTemplateInstantiationArgs in clang/lib/Sema/SemaTemplateInstantiate.cpp around the reported assertion. Trace the variable-template instantiation path and add regression coverage for this case; done means the reproducer no longer triggers the assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.