[clang] crash when combining CTAD+std::invocable+alias template
Clang crashes when compiling the following code with clang -std=c++20 main.cpp.
Confirmed with clang-19.1.4 and trunk(84af3ee).
main.cpp:
#include <functional>
template <class Ret, class... Args>
struct SomeLongStructName {
SomeLongStructName(std::function<Ret(Args...)>, Args...) {}
};
template <class Lambda, class... Args>
requires std::invocable<Lambda, Args...>
SomeLongStructName(Lambda lambda, Args... args) -> SomeLongStructName<std::invoke_result_t<Lambda, Args...>, Args...>;
template <class T, class... Ts>
using AliasName = SomeLongStructName<T, Ts...>;
auto main() -> int {
AliasName([](int) {}, 0);
return 0;
}
Crash dump:
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-trunk/bin/clang++ -gdwarf-4 -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 -std=c++20 <source>
1. <source>:16:29: current parser token ';'
2. <source>:15:20: parsing function body 'main'
3. <source>:15:20: in compound statement ('{}')
#0 0x0000000003ab3738 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ab3738)
#1 0x0000000003ab187c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ab187c)
#2 0x0000000003a00bb8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007b0685442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000000000782ea93 clang::TemplateArgument::containsUnexpandedParameterPack() const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x782ea93)
#5 0x0000000006eda160 bool clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::TemplateArgumentLoc const*>(clang::TemplateArgumentLoc const*, clang::TemplateArgumentLoc const*, clang::TemplateArgumentListInfo&, bool) (.constprop.0) SemaTemplateInstantiate.cpp:0:0
#6 0x0000000006edafde clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformConceptSpecializationExpr(clang::ConceptSpecializationExpr*) SemaTemplateInstantiate.cpp:0:0
#7 0x0000000006ec2243 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#8 0x0000000006ef0445 clang::Sema::SubstExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6ef0445)
#9 0x0000000006e4260b (anonymous namespace)::BuildDeductionGuideForTypeAlias(clang::Sema&, clang::TypeAliasTemplateDecl*, clang::FunctionTemplateDecl*, clang::SourceLocation) SemaTemplateDeductionGuide.cpp:0:0
#10 0x0000000006e819c2 clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6e819c2)
#11 0x0000000006a7dd00 LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) SemaLookup.cpp:0:0
#12 0x0000000006a69b94 clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6a69b94)
#13 0x0000000006a3de4c clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6a3de4c)
#14 0x00000000069259ab clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x69259ab)
#15 0x000000000699b37d clang::Sema::ActOnCXXTypeConstructExpr(clang::OpaquePtr<clang::QualType>, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x699b37d)
#16 0x00000000063d6901 clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63d6901)
#17 0x00000000063c5e01 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c5e01)
#18 0x00000000063c699a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c699a)
#19 0x00000000063c6b69 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c6b69)
#20 0x00000000063cbe09 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63cbe09)
#21 0x00000000064595a7 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x64595a7)
#22 0x000000000644cd37 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644cd37)
#23 0x000000000644d72d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644d72d)
#24 0x000000000644ea44 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644ea44)
#25 0x000000000644fbfa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644fbfa)
#26 0x000000000634b226 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634b226)
#27 0x00000000063954ef clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63954ef)
#28 0x00000000063437f7 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63437f7)
#29 0x000000000634460e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634460e)
#30 0x000000000634df02 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634df02)
#31 0x000000000634f798 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634f798)
#32 0x000000000633ddfa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x633ddfa)
#33 0x00000000044038f5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44038f5)
#34 0x00000000046db8d1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x46db8d1)
#35 0x000000000465b2eb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x465b2eb)
#36 0x00000000047c6973 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x47c6973)
#37 0x0000000000d106a1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd106a1)
#38 0x0000000000d08e9d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#39 0x000000000444f159 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
#40 0x0000000003a00fe3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a00fe3)
#41 0x000000000444f379 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
#42 0x000000000441351d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x441351d)
#43 0x00000000044144b1 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44144b1)
#44 0x000000000441e83c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x441e83c)
#45 0x0000000000d0d331 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd0d331)
#46 0x0000000000bd3054 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xbd3054)
#47 0x00007b0685429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#48 0x00007b0685429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#49 0x0000000000d08935 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd08935)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
@llvm/issue-subscribers-clang-frontend
Author: mojyack (mojyack)
main.cpp:
#include <functional>
template <class Ret, class... Args>
struct SomeLongStructName {
SomeLongStructName(std::function<Ret(Args...)>, Args...) {}
};
template <class Lambda, class... Args>
requires std::invocable<Lambda, Args...>
SomeLongStructName(Lambda lambda, Args... args) -> SomeLongStructName<std::invoke_result_t<Lambda, Args...>, Args...>;
template <class T, class... Ts>
using AliasName = SomeLongStructName<T, Ts...>;
auto main() -> int {
AliasName([](int) {}, 0);
return 0;
}
Crash dump:
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-trunk/bin/clang++ -gdwarf-4 -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 -std=c++20 <source>
1. <source>:16:29: current parser token ';'
2. <source>:15:20: parsing function body 'main'
3. <source>:15:20: in compound statement ('{}')
#<!-- -->0 0x0000000003ab3738 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ab3738)
#<!-- -->1 0x0000000003ab187c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ab187c)
#<!-- -->2 0x0000000003a00bb8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#<!-- -->3 0x00007b0685442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#<!-- -->4 0x000000000782ea93 clang::TemplateArgument::containsUnexpandedParameterPack() const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x782ea93)
#<!-- -->5 0x0000000006eda160 bool clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::TemplateArgumentLoc const*>(clang::TemplateArgumentLoc const*, clang::TemplateArgumentLoc const*, clang::TemplateArgumentListInfo&, bool) (.constprop.0) SemaTemplateInstantiate.cpp:0:0
#<!-- -->6 0x0000000006edafde clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformConceptSpecializationExpr(clang::ConceptSpecializationExpr*) SemaTemplateInstantiate.cpp:0:0
#<!-- -->7 0x0000000006ec2243 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#<!-- -->8 0x0000000006ef0445 clang::Sema::SubstExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6ef0445)
#<!-- -->9 0x0000000006e4260b (anonymous namespace)::BuildDeductionGuideForTypeAlias(clang::Sema&, clang::TypeAliasTemplateDecl*, clang::FunctionTemplateDecl*, clang::SourceLocation) SemaTemplateDeductionGuide.cpp:0:0
#<!-- -->10 0x0000000006e819c2 clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6e819c2)
#<!-- -->11 0x0000000006a7dd00 LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) SemaLookup.cpp:0:0
#<!-- -->12 0x0000000006a69b94 clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6a69b94)
#<!-- -->13 0x0000000006a3de4c clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6a3de4c)
#<!-- -->14 0x00000000069259ab clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x69259ab)
#<!-- -->15 0x000000000699b37d clang::Sema::ActOnCXXTypeConstructExpr(clang::OpaquePtr<clang::QualType>, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x699b37d)
#<!-- -->16 0x00000000063d6901 clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63d6901)
#<!-- -->17 0x00000000063c5e01 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c5e01)
#<!-- -->18 0x00000000063c699a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c699a)
#<!-- -->19 0x00000000063c6b69 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c6b69)
#<!-- -->20 0x00000000063cbe09 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63cbe09)
#<!-- -->21 0x00000000064595a7 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x64595a7)
#<!-- -->22 0x000000000644cd37 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644cd37)
#<!-- -->23 0x000000000644d72d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644d72d)
#<!-- -->24 0x000000000644ea44 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644ea44)
#<!-- -->25 0x000000000644fbfa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x644fbfa)
#<!-- -->26 0x000000000634b226 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634b226)
#<!-- -->27 0x00000000063954ef clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63954ef)
#<!-- -->28 0x00000000063437f7 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63437f7)
#<!-- -->29 0x000000000634460e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634460e)
#<!-- -->30 0x000000000634df02 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634df02)
#<!-- -->31 0x000000000634f798 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634f798)
#<!-- -->32 0x000000000633ddfa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x633ddfa)
#<!-- -->33 0x00000000044038f5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44038f5)
#<!-- -->34 0x00000000046db8d1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x46db8d1)
#<!-- -->35 0x000000000465b2eb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x465b2eb)
#<!-- -->36 0x00000000047c6973 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x47c6973)
#<!-- -->37 0x0000000000d106a1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd106a1)
#<!-- -->38 0x0000000000d08e9d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#<!-- -->39 0x000000000444f159 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
#<!-- -->40 0x0000000003a00fe3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a00fe3)
#<!-- -->41 0x000000000444f379 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
#<!-- -->42 0x000000000441351d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x441351d)
#<!-- -->43 0x00000000044144b1 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44144b1)
#<!-- -->44 0x000000000441e83c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x441e83c)
#<!-- -->45 0x0000000000d0d331 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd0d331)
#<!-- -->46 0x0000000000bd3054 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xbd3054)
#<!-- -->47 0x00007b0685429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->48 0x00007b0685429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->49 0x0000000000d08935 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd08935)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
So it looks like this has something to do w/ std::invoke_result_t, so we need a reduction to figure out what is really going on.
template <class T, class... Args>
concept invocable = true;
template <class T, class... Args>
struct SomeLongStructName {
SomeLongStructName(T, Args...) {}
};
template <class Lambda, class... Args>
requires invocable<Lambda, Args...>
SomeLongStructName(Lambda lambda, Args... args) -> SomeLongStructName<Lambda, Args...>;
template <class T, class... Ts>
using AliasName = SomeLongStructName<T, Ts...>;
int main() {
AliasName([](int) {}, 0);
return 0;
}
https://godbolt.org/z/cnT35EEYo
clang++: /root/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:2582: clang::QualType {anonymous}::TemplateInstantiator::TransformTemplateTypeParmType(clang::TypeLocBuilder&, clang::TemplateTypeParmTypeLoc, bool): Assertion `Arg.pack_size() == 1 && Arg.pack_begin()->isPackExpansion() && "unexpected pack arguments in template rewrite"' failed.
Looks like a substitution bug.
@antangelo @hokein
This original input seems to still trigger assertion. https://godbolt.org/z/eWxreG17c
Is this a crash-on-valid or invalid? I am not familar with it since earlier versions of clang rejects it while gcc accepts it.
I am afraid #126206 claims Fixes #124715, but that does not hold for the original repro.
#include <functional>
template <class Ret, class... Args>
struct SomeLongStructName {
SomeLongStructName(std::function<Ret(Args...)>, Args...) {}
};
template <class Lambda, class... Args>
requires std::invocable<Lambda, Args...>
SomeLongStructName(Lambda lambda, Args... args) -> SomeLongStructName<std::invoke_result_t<Lambda, Args...>, Args...>;
template <class T, class... Ts>
using AliasName = SomeLongStructName<T, Ts...>;
auto main() -> int {
AliasName([](int) {}, 0);
return 0;
}
I ran manyclangs at the merge commit c08b80eb and its parent 2a7487cc:
- parent: original ICEs
- c08b80eb: the GH124715 / concept-invocable=true reductions are rc=0;
the original still ICEs in TemplateArgument::getPackAsArray
(
getKind() == Pack). Trunk still ICEs on the original.
Reduced:
template <class T>
T&& declval();
template <class F, class... Args>
auto invoke(F&& f, Args&&... args)
-> decltype(static_cast<F&&>(f)(static_cast<Args&&>(args)...));
template <class F, class... Args>
using invoke_result_t = decltype(invoke(declval<F>(), declval<Args>()...));
template <class F, class... Args>
concept invocable = requires(F&& f, Args&&... args) {
invoke(static_cast<F&&>(f), static_cast<Args&&>(args)...);
};
template <class Ret, class... Args>
struct A {
A(auto&&...) {}
};
template <class Lambda, class... Args>
requires invocable<Lambda, Args...>
A(Lambda, Args...) -> A<invoke_result_t<Lambda, Args...>, Args...>;
template <class T, class... Ts>
using AliasName = A<T, Ts...>;
int main() {
AliasName([](int){}, 0);
}
See https://compiler-explorer.com/z/oerq96xen
Assertion:
clang++: /root/llvm-project/llvm/tools/clang/include/clang/AST/TemplateBase.h:444:
llvm::ArrayRef<clang::TemplateArgument> clang::TemplateArgument::getPackAsArray() const:
Assertion `getKind() == Pack' failed.