<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65153>65153</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang crashes on variable template instantiated with a member of a template class
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
oliora
</td>
</tr>
</table>
<pre>
clang version 16.0.0 (https://github.com/llvm/llvm-project.git 08d094a0e457360ad8b94b017d2dc277e697ca76)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-16.0.0/bin
Log and the crash 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-16.0.0/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-12.2.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <source>:55:67: current parser token ';'
2. <source>:40:1: parsing struct/union/class body 'Builder'
#0 0x000055ed179d48df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x3ba18df)
#1 0x000055ed179d290c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x3b9f90c)
#2 0x000055ed17925518 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fc08950c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x000055ed1a94d2e9 clang::Sema::SubstituteExplicitTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo&, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, llvm::SmallVectorImpl<clang::QualType>&, clang::QualType*, clang::sema::TemplateDeductionInfo&) (.constprop.0) SemaTemplateDeduction.cpp:0:0
#5 0x000055ed1a94dd75 void llvm::function_ref<void ()>::callback_fn<clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool)::'lambda'()>(long) SemaTemplateDeduction.cpp:0:0
#6 0x000055ed1a041eb5 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x620eeb5)
#7 0x000055ed1a98a059 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6b57059)
#8 0x000055ed1a98a6cb clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6b576cb)
#9 0x000055ed1a7a79aa clang::Sema::ResolveSingleFunctionTemplateSpecialization(clang::OverloadExpr*, bool, clang::DeclAccessPair*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x69749aa)
#10 0x000055ed1a98b52f ResolveOverloadForDeduction(clang::Sema&, clang::TemplateParameterList*, clang::Expr*, clang::QualType, bool) SemaTemplateDeduction.cpp:0:0
#11 0x000055ed1a98bcde DeduceTemplateArgumentsFromCallArgument(clang::Sema&, clang::TemplateParameterList*, unsigned int, clang::QualType, clang::Expr*, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg>&, bool, unsigned int, unsigned int) SemaTemplateDeduction.cpp:0:0
#12 0x000055ed1a98ccad clang::Sema::DeduceAutoType(clang::TypeLoc, clang::Expr*, clang::QualType&, clang::sema::TemplateDeductionInfo&, bool, bool) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6b59cad)
#13 0x000055ed1a215087 clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x63e2087)
#14 0x000055ed1a22a93f clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x63f793f)
#15 0x000055ed1a253eed clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6420eed)
#16 0x000055ed19f47bc9 clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6114bc9)
#17 0x000055ed19f48db4 clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&, clang::ParsedAttributes&, clang::TypeSpecifierType, clang::Decl*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6115db4)
#18 0x000055ed19f49453 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6116453)
#19 0x000055ed19f4b7fe clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x61187fe)
#20 0x000055ed19f1c01e clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x60e901e)
#21 0x000055ed19ff42b7 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x61c12b7)
#22 0x000055ed19ffcc5d clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x61c9c5d)
#23 0x000055ed19ffcf43 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x61c9f43)
#24 0x000055ed19f28d0f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x60f5d0f)
#25 0x000055ed19ef88a5 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x60c58a5)
#26 0x000055ed19efa72d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x60c772d)
#27 0x000055ed19ee9a8a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x60b6a8a)
#28 0x000055ed18cc4865 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x4e91865)
#29 0x000055ed185a0671 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x476d671)
#30 0x000055ed18524993 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x46f1993)
#31 0x000055ed18684b3b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x4851b3b)
#32 0x000055ed151ad41c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x137a41c)
#33 0x000055ed151a8bdc ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#34 0x000055ed18385ce9 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
#35 0x000055ed17925977 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x3af2977)
#36 0x000055ed18385f1c 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
#37 0x000055ed1834e3fc clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x451b3fc)
#38 0x000055ed1834eded clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x451bded)
#39 0x000055ed1835923c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x452623c)
#40 0x000055ed151ab523 clang_main(int, char**) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x1378523)
#41 0x00007fc088fba083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#42 0x000055ed151a4d1e _start (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x1371d1e)
clang-16: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
Minimal code:
```cpp
#include <string_view>
#include <array>
template <const std::string_view&... Strs>
struct Join {
static constexpr auto impl() noexcept {
// Logic does not matter
std::array<char, (Strs.size() + ... + 0)> arr{};
return arr;
}
static constexpr auto arr = impl();
static constexpr std::string_view value{ arr.data(), arr.size() - 1 };
};
template <const std::string_view&... Strs>
constexpr std::string_view JoinStringViews = details::Join<Strs...>::value;
static constexpr std::string_view LengthValue = "12345678";
enum class Version { v1, v2 };
template <Version V>
class Builder {
public:
static constexpr std::string_view Equal = "=";
// Crash is happening for this line
// No crash without passing a template member `Equal`
static constexpr auto Val = JoinStringViews<Equal, LengthValue>;
// Note that the following line compiles just fine
// static constexpr auto Val = Join<Equal, LengthValue>::value;
};
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkW1tz2ziW_jX0C0oqELw_-EGW49n0uifZOOWdNxcIgDImEMABQEeZX78FkJII6mInUVJdO10dWSJxOec7Hz4cgCA2hq8kY9dRdhNlt1e4s89KXyvBlcZXtaLfronAcgVemDZcSRDncziHIELls7WtiZJFhO4idLfi9rmr50StI3QnxMv2z6zV6p-M2PmKWwBLCqsUQ5ZmRZJDTMu6SmsYFxRRgoqC5VVBcJFHqIrgbQQXn7FeMRslC7Ap86c8nXXyi1Rf5Uxw2W1mK9kN5Z41wxSsFWXClW6V4Zv-1ntpLBaC0Vuu3a0I3anWRuiOqHXLBdMztmmF0ky7a87XWe9jhO5qLvtG-s97tQJYUmCfGSAam2dQY_LFakyYw2FUMsrh8L__-fH-3eLhHTBdveYWYFB3K6BZq7QFVoHvAzJCd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