[Clang 22.1.0] [Regression] ICE (segfault) when using CTAD for alias template with a non-dependent template argument
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following code started failing(ICE) on Clang 22.1.0 (passed in 21, 20; ICE in 19; failed in 18, 17)
```cpp
# include
// __cpp_deduction_guides >= 201907L
template
struct function {
template = 0>
function(U) noexcept {}
};
template
function(T) -> function;
template
using basic_fn = function>;
template
using fn_ref = basic_fn;
int main() {
fn_ref f = 0;
}
```
The full error is:
```txt
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-22.1.0/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-15.2.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 -O0
1. :21:17: current parser token ';'
2. :20:12: parsing function body 'main'
3. :20:12: in compound statement ('{}')
#0 0x0000000003cdda28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x3cdda28)
#1 0x0000000003cdb3fc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x3cdb3fc)
#2 0x0000000003c204e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f3ed6a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000000000781ad84 clang::TemplateArgument::isPackExpansion() const (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x781ad84)
#5 0x0000000006c394af clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::TemplateParameterList*, clang::SourceLocation, clang::TemplateArgumentListInfo&, clang::DefaultArguments const&, bool, clang::Sema::CheckTemplateArgumentInfo&, bool, bool*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6c394af)
#6 0x0000000006c4669d clang::Sema::CheckTemplateIdType(clang::ElaboratedTypeKeyword, clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&, clang::Scope*, bool) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6c4669d)
#7 0x0000000006d6b5b5 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::QualType, clang::NamedDecl*, bool) SemaTemplateInstantiate.cpp:0:0
#8 0x0000000006d50337 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformNestedNameSpecifierLoc(clang::NestedNameSpecifierLoc, clang::QualType, clang::NamedDecl*) SemaTemplateInstantiate.cpp:0:0
#9 0x0000000006d6c95f clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDependentScopeDeclRefExpr(clang::DependentScopeDeclRefExpr*, bool, clang::TypeSourceInfo**) SemaTemplateInstantiate.cpp:0:0
#10 0x0000000006d4383d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#11 0x0000000006d78293 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformUnaryOperator(clang::UnaryOperator*) SemaTemplateInstantiate.cpp:0:0
#12 0x0000000006d43d47 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#13 0x0000000006d4379e clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#14 0x0000000006d53d7e clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
#15 0x0000000006d6b4f5 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::QualType, clang::NamedDecl*, bool) SemaTemplateInstantiate.cpp:0:0
#16 0x0000000006d4bf07 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#17 0x0000000006d4d747 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
#18 0x0000000006d50f2f clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, bool) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6d50f2f)
#19 0x0000000006dbf6a3 clang::TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(clang::NonTypeTemplateParmDecl*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6dbf6a3)
#20 0x0000000006e20ef4 void llvm::function_ref::callback_fn(long) SemaTemplateInstantiateDecl.cpp:0:0
#21 0x0000000007bbf721 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x7bbf721)
#22 0x0000000006dc0d8a clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6dc0d8a)
#23 0x0000000006ce321d (anonymous namespace)::transformTemplateParameter(clang::Sema&, clang::DeclContext*, clang::NamedDecl*, clang::MultiLevelTemplateArgumentList&, unsigned int, unsigned int, bool) SemaTemplateDeductionGuide.cpp:0:0
#24 0x0000000006ce689a (anonymous namespace)::BuildDeductionGuideForTypeAlias(clang::Sema&, clang::TypeAliasTemplateDecl*, clang::FunctionTemplateDecl*, clang::SourceLocation) SemaTemplateDeductionGuide.cpp:0:0
#25 0x0000000006d286d5 clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*, clang::SourceLocation) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6d286d5)
#26 0x00000000069169d0 LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) SemaLookup.cpp:0:0
#27 0x0000000006916bfd clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6916bfd)
#28 0x00000000068da2a3 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x68da2a3)
#29 0x00000000065c84c8 clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x65c84c8)
#30 0x00000000065d8d7b clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x65d8d7b)
#31 0x0000000006601add clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6601add)
#32 0x000000000624d4f6 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x624d4f6)
#33 0x0000000006261cec clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6261cec)
#34 0x00000000062646fc clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x62646fc)
#35 0x0000000006264b4a clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6264b4a)
#36 0x0000000006320c08 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6320c08)
#37 0x00000000063215b6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x63215b6)
#38 0x000000000632a1d9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x632a1d9)
#39 0x000000000632ac7a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x632ac7a)
#40 0x000000000621578b clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x621578b)
#41 0x000000000626214f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x626214f)
#42 0x000000000620eb77 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x620eb77)
#43 0x000000000620f317 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x620f317)
#44 0x0000000006217cdf clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x6217cdf)
#45 0x00000000062194e7 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x62194e7)
#46 0x00000000061f232a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x61f232a)
#47 0x00000000045b1015 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x45b1015)
#48 0x00000000048c4eea clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x48c4eea)
#49 0x0000000004842d1b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x4842d1b)
#50 0x00000000049bb3ab clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x49bb3ab)
#51 0x0000000000dd7b0d cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0xdd7b0d)
#52 0x0000000000dcf94b ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#53 0x0000000000dcf9ed int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#54 0x000000000462bab9 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#55 0x0000000003c20903 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x3c20903)
#56 0x000000000462bcd9 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#57 0x00000000045eedb2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x45eedb2)
#58 0x00000000045efc91 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x45efc91)
#59 0x00000000045f879c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0x45f879c)
#60 0x0000000000dd4419 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0xdd4419)
#61 0x0000000000c89e24 main (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0xc89e24)
#62 0x00007f3ed6a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#63 0x00007f3ed6a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#64 0x0000000000dcf3e5 _start (/opt/compiler-explorer/clang-22.1.0/bin/clang+++0xdcf3e5)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
Contributor guide
Assessment
This issue has not been assessed yet.