[Clang][Regression] CTAD failure for alias template with non-type template argument
Consider the following C++20 code:
template <class T, T>
struct A {};
template <class T>
using AA = A<T, T{}>;
AA<int> a;
AA b{a};
Error since Clang trunk:
<source>:8:4: error: no viable constructor or deduction guide for deduction of template arguments of 'AA'
8 | AA b{a};
| ^
<source>:5:1: note: candidate template ignored: deduced type 'A<[...], int{}>' of 1st parameter does not match adjusted type 'A<[...], int{} aka 0>' of argument [with T = int]
5 | using AA = A<T, T{}>;
| ^
<source>:5:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(AA, A<T, T{}>) AA(A<T, T{}>) -> A<T, T{}>'
<source>:5:1: note: candidate function template not viable: requires 0 arguments, but 1 was provided
<source>:5:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(AA, A<T, T{}>) AA() -> A<T, T{}>'
1 error generated.
See https://compiler-explorer.com/z/jdeo8ajcc.
@llvm/issue-subscribers-clang-frontend
Author: None (MagentaTreehouse)
template <class T> using AA = A<T, T{}>;
AA<int> a; AA b{a};
Error since Clang trunk:
```console
<source>:8:4: error: no viable constructor or deduction guide for deduction of template arguments of 'AA'
8 | AA b{a};
| ^
<source>:5:1: note: candidate template ignored: deduced type 'A<[...], int{}>' of 1st parameter does not match adjusted type 'A<[...], int{} aka 0>' of argument [with T = int]
5 | using AA = A<T, T{}>;
| ^
<source>:5:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(AA, A<T, T{}>) AA(A<T, T{}>) -> A<T, T{}>'
<source>:5:1: note: candidate function template not viable: requires 0 arguments, but 1 was provided
<source>:5:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(AA, A<T, T{}>) AA() -> A<T, T{}>'
1 error generated.
See https://compiler-explorer.com/z/jdeo8ajcc.
CC @mizvekov @hubert-reinterpretcast was this change on purpose?
Bisects to a crash introduced in https://github.com/llvm/llvm-project/commit/078e99ef017cac3899e5dbc2ed917f173c9eedad @mizvekov .
Assertion:
Assertion failed: !isValueDependent() && "Expression evaluator can't be called on a dependent expression.",
file D:/dev/source/llvm-project/clang/lib/AST/ExprConstant.cpp, line 17876
Stack dump
0. Program arguments: D:\\dev\\build\\llvm\\Clang-cl_21-Debug\\bin\\clang++.exe -cc1 -triple x86_64-pc-windows-msvc19.50.35719 -emit-obj -mincremental-linker-compatible -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -fms-volatile -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -fdebug-compilation-dir=D:\\dev\\CppExamples -fcoverage-compilation-dir=D:\\dev\\CppExamples -resource-dir D:\\dev\\build\\llvm\\Clang-cl_21-Debug\\lib\\clang\\22 -internal-isystem D:\\dev\\build\\llvm\\Clang-cl_21-Debug\\lib\\clang\\22\\include -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\ATLMFC\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Auxiliary\\VS\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.26100.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\cppwinrt" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\ATLMFC\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Auxiliary\\VS\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.26100.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\cppwinrt" -std=c++20 -fdeprecated-macro -ferror-limit 19 -fmessage-length=110 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.50.35719 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -o C:\\Users\\TREEHO~1\\AppData\\Local\\Temp\\test-0124f5.o -x c++ .\\test.cpp
1. .\test.cpp:8:8: current parser token ';'
Exception Code: 0xC000001D
#0 0x00007ff7e5f1146c HandleAbort D:\dev\source\llvm-project\llvm\lib\Support\Windows\Signals.inc:372:0
#1 0x00007ffa6e8d9e77 (C:\Windows\SYSTEM32\ucrtbased.dll+0x99e77)
#2 0x00007ffa6e8dbab9 (C:\Windows\SYSTEM32\ucrtbased.dll+0x9bab9)
#3 0x00007ffa6e8e1715 (C:\Windows\SYSTEM32\ucrtbased.dll+0xa1715)
#4 0x00007ffa6e8e1387 (C:\Windows\SYSTEM32\ucrtbased.dll+0xa1387)
#5 0x00007ffa6e8df351 (C:\Windows\SYSTEM32\ucrtbased.dll+0x9f351)
#6 0x00007ffa6e8e1c7f (C:\Windows\SYSTEM32\ucrtbased.dll+0xa1c7f)
#7 0x00007ff7e979a6eb clang::Expr::EvaluateAsConstantExpr(struct clang::Expr::EvalResult &, class clang::ASTContext const &, enum clang::Expr::ConstantExprKind) const D:\dev\source\llvm-project\clang\lib\AST\ExprConstant.cpp:17878:0
#8 0x00007ff7ed2d1de2 calculateConstraintSatisfaction D:\dev\source\llvm-project\clang\lib\Sema\SemaConcept.cpp:533:0
#9 0x00007ff7ed2d9c9a calculateConstraintSatisfaction D:\dev\source\llvm-project\clang\lib\Sema\SemaConcept.cpp:560:0
#10 0x00007ff7ed2d154d CheckConstraintSatisfaction D:\dev\source\llvm-project\clang\lib\Sema\SemaConcept.cpp:599:0
#11 0x00007ff7ed2d10ed clang::Sema::CheckConstraintSatisfaction(class clang::NamedDecl const *, class llvm::ArrayRef<struct clang::AssociatedConstraint>, class llvm::SmallVectorImpl<class clang::Expr *> &, class clang::MultiLevelTemplateArgumentList const &, class clang::SourceRange, class clang::ConstraintSatisfaction &) D:\dev\source\llvm-project\clang\lib\Sema\SemaConcept.cpp:658:0
#12 0x00007ff7eaa4f232 clang::Sema::CheckConstraintSatisfaction(class clang::NamedDecl const *, class llvm::ArrayRef<struct clang::AssociatedConstraint>, class clang::MultiLevelTemplateArgumentList const &, class clang::SourceRange, class clang::ConstraintSatisfaction &) D:\dev\source\llvm-project\clang\include\clang\Sema\Sema.h:14738:0
#13 0x00007ff7ed2d44ad CheckFunctionConstraintsWithoutInstantiation D:\dev\source\llvm-project\clang\lib\Sema\SemaConcept.cpp:1109:0
#14 0x00007ff7ed2d3dcc clang::Sema::CheckFunctionTemplateConstraints(class clang::SourceLocation, class clang::FunctionDecl *, class llvm::ArrayRef<class clang::TemplateArgument>, class clang::ConstraintSatisfaction &) D:\dev\source\llvm-project\clang\lib\Sema\SemaConcept.cpp:1121:0
#15 0x00007ff7ed1fb642 clang::Sema::FinishTemplateArgumentDeduction(class clang::FunctionTemplateDecl *, class llvm::SmallVectorImpl<class clang::DeducedTemplateArgument> &, unsigned int, class clang::FunctionDecl *&, class clang::sema::TemplateDeductionInfo &, class llvm::SmallVectorImpl<struct clang::Sema::OriginalCallArg> const *, bool, bool, bool, class llvm::function_ref<(bool)>) D:\dev\source\llvm-project\clang\lib\Sema\SemaTemplateDeduction.cpp:3995:0
#16 0x00007ff7ed2a828f clang::Sema::DeduceTemplateArguments::<lambda_3>::operator() D:\dev\source\llvm-project\clang\lib\Sema\SemaTemplateDeduction.cpp:4735:0
#17 0x00007ff7ed2a8193 llvm::function_ref<void ()>::callback_fn<`lambda at D:\dev\source\llvm-project\clang\lib\Sema\SemaTemplateDeduction.cpp:4734:51'> D:\dev\source\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:46:0
#18 0x00007ff7e5ec8157 llvm::function_ref<(void)>::operator()(void) const D:\dev\source\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:69:0
#19 0x00007ff7e95d0939 clang::runWithSufficientStackSpace(class llvm::function_ref<(void)>, class llvm::function_ref<(void)>) D:\dev\source\llvm-project\clang\include\clang\Basic\Stack.h:49:0
#20 0x00007ff7e95d06bc clang::StackExhaustionHandler::runWithSufficientStackSpace(class clang::SourceLocation, class llvm::function_ref<(void)>) D:\dev\source\llvm-project\clang\lib\Basic\StackExhaustionHandler.cpp:20:0
#21 0x00007ff7e7e8acc4 clang::Sema::runWithSufficientStackSpace(class clang::SourceLocation, class llvm::function_ref<(void)>) D:\dev\source\llvm-project\clang\lib\Sema\Sema.cpp:629:0
#22 0x00007ff7ed1fe5aa clang::Sema::DeduceTemplateArguments(class clang::FunctionTemplateDecl *, class clang::TemplateArgumentListInfo *, class llvm::ArrayRef<class clang::Expr *>, class clang::FunctionDecl *&, class clang::sema::TemplateDeductionInfo &, bool, bool, bool, class clang::QualType, class clang::Expr::Classification, bool, class llvm::function_ref<(class llvm::ArrayRef<class clang::QualType>, bool)>) D:\dev\source\llvm-project\clang\lib\Sema\SemaTemplateDeduction.cpp:4745:0
#23 0x00007ff7eabaf247 AddTemplateOverloadCandidateImmediately D:\dev\source\llvm-project\clang\lib\Sema\SemaOverload.cpp:8024:0
#24 0x00007ff7eabbd1b5 AddTemplateOverloadCandidate D:\dev\source\llvm-project\clang\lib\Sema\SemaOverload.cpp:11256:0
#25 0x00007ff7eabbd000 clang::OverloadCandidateSet::InjectNonDeducedTemplateCandidates(class clang::Sema &) D:\dev\source\llvm-project\clang\lib\Sema\SemaOverload.cpp:11281:0
#26 0x00007ff7eaba8502 clang::OverloadCandidateSet::BestViableFunction(class clang::Sema &, class clang::SourceLocation, struct clang::OverloadCandidate *&) D:\dev\source\llvm-project\clang\lib\Sema\SemaOverload.cpp:11374:0
#27 0x00007ff7ea8060de clang::Sema::DeduceTemplateSpecializationFromInitializer::<lambda_0>::operator() D:\dev\source\llvm-project\clang\lib\Sema\SemaInit.cpp:10206:0
#28 0x00007ff7ea8052f2 clang::Sema::DeduceTemplateSpecializationFromInitializer(class clang::TypeSourceInfo *, class clang::InitializedEntity const &, class clang::InitializationKind const &, class llvm::MutableArrayRef<class clang::Expr *>) D:\dev\source\llvm-project\clang\lib\Sema\SemaInit.cpp:10250:0
#29 0x00007ff7ea27bef3 clang::Sema::deduceVarTypeFromInitializer(class clang::VarDecl *, class clang::DeclarationName, class clang::QualType, class clang::TypeSourceInfo *, class clang::SourceRange, bool, class clang::Expr *) D:\dev\source\llvm-project\clang\lib\Sema\SemaDecl.cpp:13198:0
#30 0x00007ff7ea27cc1d clang::Sema::DeduceVariableDeclarationType(class clang::VarDecl *, bool, class clang::Expr *) D:\dev\source\llvm-project\clang\lib\Sema\SemaDecl.cpp:13297:0
#31 0x00007ff7ea27dfe6 clang::Sema::AddInitializerToDecl(class clang::Decl *, class clang::Expr *, bool) D:\dev\source\llvm-project\clang\lib\Sema\SemaDecl.cpp:13789:0
#32 0x00007ff7ee06a0a2 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(class clang::Declarator &,
struct clang::Parser::ParsedTemplateInfo const &, struct clang::Parser::ForRangeInit *) D:\dev\source\llvm-project\clang\lib\Parse\ParseDecl.cpp:2711:0
#33 0x00007ff7ee067d71 clang::Parser::ParseDeclGroup(class clang::ParsingDeclSpec &, enum clang::DeclaratorContext, class clang::ParsedAttributes &, struct clang::Parser::ParsedTemplateInfo &, class clang::SourceLocation *, struct clang::Parser::ForRangeInit *) D:\dev\source\llvm-project\clang\lib\Parse\ParseDecl.cpp:2352:0
#34 0x00007ff7ed6426cc clang::Parser::ParseDeclOrFunctionDefInternal(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec &, enum clang::AccessSpecifier) D:\dev\source\llvm-project\clang\lib\Parse\Parser.cpp:1187:0
#35 0x00007ff7ed641ad1 clang::Parser::ParseDeclarationOrFunctionDefinition(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec *, enum clang::AccessSpecifier) D:\dev\source\llvm-project\clang\lib\Parse\Parser.cpp:1209:0
#36 0x00007ff7ed6412c6 clang::Parser::ParseExternalDeclaration(class clang::ParsedAttributes &, class clang::ParsedAttributes &, class clang::ParsingDeclSpec *) D:\dev\source\llvm-project\clang\lib\Parse\Parser.cpp:1032:0
#37 0x00007ff7ed63ebe2 clang::Parser::ParseTopLevelDecl(class clang::OpaquePtr<class clang::DeclGroupRef> &, enum clang::Sema::ModuleImportState &) D:\dev\source\llvm-project\clang\lib\Parse\Parser.cpp:745:0
#38 0x00007ff7eaf37717 clang::ParseAST(class clang::Sema &, bool, bool) D:\dev\source\llvm-project\clang\lib\Parse\ParseAST.cpp:170:0
#39 0x00007ff7e7eed8af clang::ASTFrontendAction::ExecuteAction(void) D:\dev\source\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1436:0
#40 0x00007ff7e803498f clang::CodeGenAction::ExecuteAction(void) D:\dev\source\llvm-project\clang\lib\CodeGen\CodeGenAction.cpp:1114:0
#41 0x00007ff7e7eed20f clang::FrontendAction::Execute(void) D:\dev\source\llvm-project\clang\lib\Frontend\FrontendAction.cpp:1318:0
#42 0x00007ff7e61f9db8 clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) D:\dev\source\llvm-project\clang\lib\Frontend\CompilerInstance.cpp:1007:0
#43 0x00007ff7e631998e clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) D:\dev\source\llvm-project\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:310:0
#44 0x00007ff7e5660a06 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) D:\dev\source\llvm-project\clang\tools\driver\cc1_main.cpp:300:0
#45 0x00007ff7e5652770 ExecuteCC1Tool D:\dev\source\llvm-project\clang\tools\driver\driver.cpp:225:0
#46 0x00007ff7e56514e8 clang_main(int, char **, struct llvm::ToolContext const &) D:\dev\source\llvm-project\clang\tools\driver\driver.cpp:268:0
#47 0x00007ff7e568a0c2 main D:\dev\build\llvm\Clang-cl_21-Debug\tools\clang\tools\driver\clang-driver.cpp:17:0#48 0x00007ff7eed3b9d9 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#49 0x00007ff7eed3bb12 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#50 0x00007ff7eed3bb9e __scrt_common_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#51 0x00007ff7eed3bbbe mainCRTStartup D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#52 0x00007ffaf3467374 (C:\Windows\System32\KERNEL32.DLL+0x17374)
#53 0x00007ffaf385cc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
Then it turns into the error since https://github.com/llvm/llvm-project/commit/e9972debc98ce5d00db47409248bbcf06fafaf73.
ping @hubert-reinterpretcast @mizvekov
This similar code causes a crash reproducible in trunk up to now:
template <class T, T>
struct A {
A(T) {}
};
template <class T>
using AA = A<T, T{}>;
AA b{0};
The crash also started in https://github.com/llvm/llvm-project/commit/078e99ef017cac3899e5dbc2ed917f173c9eedad with the same assertion I posted in https://github.com/llvm/llvm-project/issues/167513#issuecomment-3616776654.
But currently there is a different assertion hit which started in https://github.com/llvm/llvm-project/commit/e9972debc98ce5d00db47409248bbcf06fafaf73:
Assertion:
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ASTContext.cpp:6801:
clang::QualType clang::ASTContext::getDeducedTemplateSpecializationTypeInternal(clang::ElaboratedTypeKeyword, clang::TemplateName, clang::QualType, bool, clang::QualType) const:
Assertion `ID == TempID && "ID does not match"' failed.
Stack dump
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 -std=c++20 <source>
1. <source>:9:8: current parser token ';'
#0 0x00000000042ecab8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42ecab8)
#1 0x00000000042e9ee4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e9ee4)
#2 0x000000000422ec88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007c8c90242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007c8c902969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007c8c90242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007c8c902287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007c8c9022871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007c8c90239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x000000000796f254 clang::ASTContext::getDeducedTemplateSpecializationTypeInternal(clang::ElaboratedTypeKeyword, clang::TemplateName, clang::QualType, bool, clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x796f254)
#10 0x00000000079acaf2 clang::ASTContext::getDeducedTemplateSpecializationType(clang::ElaboratedTypeKeyword, clang::TemplateName, clang::QualType, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x79acaf2)
#11 0x00000000074c7620 clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateDeduction.cpp:0:0
#12 0x00000000074c83f2 clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::TypeSourceInfo*) SemaTemplateDeduction.cpp:0:0
#13 0x00000000074cd134 clang::Sema::SubstAutoTypeSourceInfo(clang::TypeSourceInfo*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74cd134)
#14 0x00000000070f1730 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70f1730)
#15 0x0000000006dd1255 clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dd1255)
#16 0x0000000006dd7117 clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dd7117)
#17 0x0000000006e04f3e clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e04f3e)
#18 0x0000000006a536e4 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a536e4)
#19 0x0000000006a610da clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a610da)
#20 0x0000000006a1e78b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a1e78b)
#21 0x0000000006a1ef7f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a1ef7f)
#22 0x0000000006a26daa clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a26daa)
#23 0x0000000006a27d45 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a27d45)
#24 0x0000000006a08dca clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a08dca)
#25 0x0000000004c4dde8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c4dde8)
#26 0x0000000004f446e5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f446e5)
#27 0x0000000004ec497e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ec497e)
#28 0x000000000503ea6d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x503ea6d)
#29 0x0000000000de5b4c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xde5b4c)
#30 0x0000000000ddc59a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#31 0x0000000000ddc71d 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
#32 0x0000000004cc0739 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
#33 0x000000000422f124 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x422f124)
#34 0x0000000004cc0d4f 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
#35 0x0000000004c81832 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c81832)
#36 0x0000000004c827de 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+++0x4c827de)
#37 0x0000000004c89c35 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c89c35)
#38 0x0000000000de1f41 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xde1f41)
#39 0x0000000000c8cf94 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc8cf94)
#40 0x00007c8c90229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#41 0x00007c8c90229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#42 0x0000000000ddc035 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xddc035)
See https://compiler-explorer.com/z/TETroaPz3.
Fixed by #200850 @mizvekov. Should we add a regression test?
Fixed by #200850 @mizvekov. Should we add a regression test?
If there are not tests in the fix that cover this specific case than we should absolutely add a regression test. Please make sure to find an appropriate existing test file to add it to.
I feel like https://github.com/llvm/llvm-project/pull/200850 has tests that covers the issue sufficiently, but this is such a nice and simple test case, adding to a severely under-tested feature (alias CTAD), that I wouldn't mind adding it.
I feel like #200850 has tests that covers the issue sufficiently, but this is such a nice and simple test case, adding to a severely under-tested feature (alias CTAD), that I wouldn't mind adding it.
Thank you, that would be awesome!
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
- Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally. Be aware that LLVM's AI policy forbids the use of AI tools to fix good first issues since it squanders a learning opportunity. Using LLMs to search and learn is permitted, since the goal is learning.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: MagentaTreehouse
template <class T> using AA = A<T, T{}>;
AA<int> a; AA b{a};
Error since Clang trunk:
```console
<source>:8:4: error: no viable constructor or deduction guide for deduction of template arguments of 'AA'
8 | AA b{a};
| ^
<source>:5:1: note: candidate template ignored: deduced type 'A<[...], int{}>' of 1st parameter does not match adjusted type 'A<[...], int{} aka 0>' of argument [with T = int]
5 | using AA = A<T, T{}>;
| ^
<source>:5:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(AA, A<T, T{}>) AA(A<T, T{}>) -> A<T, T{}>'
<source>:5:1: note: candidate function template not viable: requires 0 arguments, but 1 was provided
<source>:5:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(AA, A<T, T{}>) AA() -> A<T, T{}>'
1 error generated.
See https://compiler-explorer.com/z/jdeo8ajcc.