<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68024>68024</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Dependent value passed to function object passed to auto template parameter causes: Assertion `isa<T>(CanonicalType)` failed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davidstone
</td>
</tr>
</table>
<pre>
The following valid C++ file:
```cpp
template<auto>
struct s {
};
struct {
void operator()(int);
} f;
template<typename T>
using a = s<f(T::x)>;
```
causes clang to crash with
```console
clang++: llvm/clang/include/clang/AST/Type.h:7595: const T *clang::Type::castAs() const [T = clang::FunctionType]: Assertion `isa<T>(CanonicalType)' failed.
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: llvm/build/bin/clang++ -std=c++26 -w -o /dev/null -c a.cpp
1. a.cpp:10:11: at annotation token
#0 0x000055a0b4763262 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm/build/bin/clang+++0x4487262)
#1 0x000055a0b4760c6e llvm::sys::RunSignalHandlers() (llvm/build/bin/clang+++0x4484c6e)
#2 0x000055a0b46a81f9 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f3cdd85c710 (/usr/lib/libc.so.6+0x3e710)
#4 0x00007f3cdd8ac83c (/usr/lib/libc.so.6+0x8e83c)
#5 0x00007f3cdd85c668 gsignal (/usr/lib/libc.so.6+0x3e668)
#6 0x00007f3cdd8444b8 abort (/usr/lib/libc.so.6+0x264b8)
#7 0x00007f3cdd8443dc (/usr/lib/libc.so.6+0x263dc)
#8 0x00007f3cdd854d26 (/usr/lib/libc.so.6+0x36d26)
#9 0x000055a0b4bc042a clang::FunctionType const* clang::Type::castAs<clang::FunctionType>() const (llvm/build/bin/clang+++0x48e442a)
#10 0x000055a0b7b7e398 clang::CallExpr::getCallReturnType(clang::ASTContext const&) const (llvm/build/bin/clang+++0x78a2398)
#11 0x000055a0b7b8da34 ClassifyInternal(clang::ASTContext&, clang::Expr const*) ExprClassification.cpp:0:0
#12 0x000055a0b7b8d253 clang::Expr::ClassifyImpl(clang::ASTContext&, clang::SourceLocation*) const (llvm/build/bin/clang+++0x78b1253)
#13 0x000055a0b75e8973 clang::Sema::DeduceAutoType(clang::TypeLoc, clang::Expr*, clang::QualType&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::TemplateSpecCandidateSet*) (llvm/build/bin/clang+++0x730c973)
#14 0x000055a0b74f78e9 clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*, clang::QualType, clang::Expr*, clang::TemplateArgument&, clang::TemplateArgument&, clang::Sema::CheckTemplateArgumentKind) (llvm/build/bin/clang+++0x721b8e9)
#15 0x000055a0b74f69ca clang::Sema::CheckTemplateArgument(clang::NamedDecl*, clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation, clang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, clang::Sema::CheckTemplateArgumentKind) (llvm/build/bin/clang+++0x721a9ca)
#16 0x000055a0b74ea7b2 clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, bool, bool*) (llvm/build/bin/clang+++0x720e7b2)
#17 0x000055a0b74e9568 clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (llvm/build/bin/clang+++0x720d568)
#18 0x000055a0b74edca1 clang::Sema::ActOnTemplateIdType(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::OpaquePtr<clang::TemplateName>, clang::IdentifierInfo*, clang::SourceLocation, clang::SourceLocation, llvm::MutableArrayRef<clang::ParsedTemplateArgument>, clang::SourceLocation, bool, bool, clang::ImplicitTypenameContext) (llvm/build/bin/clang+++0x7211ca1)
#19 0x000055a0b6bf33e3 clang::Parser::AnnotateTemplateIdTokenAsType(clang::CXXScopeSpec&, clang::ImplicitTypenameContext, bool) (llvm/build/bin/clang+++0x69173e3)
#20 0x000055a0b6b3293a clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (llvm/build/bin/clang+++0x685693a)
#21 0x000055a0b6b2ecf2 clang::Parser::ParseSpecifierQualifierList(clang::DeclSpec&, clang::ImplicitTypenameContext, clang::AccessSpecifier, clang::Parser::DeclSpecContext) (llvm/build/bin/clang+++0x6852cf2)
#22 0x000055a0b6b1a7cb clang::Parser::ParseTypeName(clang::SourceRange*, clang::DeclaratorContext, clang::AccessSpecifier, clang::Decl**, clang::ParsedAttributes*) (llvm/build/bin/clang+++0x683e7cb)
#23 0x000055a0b6b50a8e clang::Parser::ParseAliasDeclarationAfterDeclarator(clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::Parser::UsingDeclarator&, clang::SourceLocation&, clang::AccessSpecifier, clang::ParsedAttributes&, clang::Decl**) (llvm/build/bin/clang+++0x6874a8e)
#24 0x000055a0b6b4f406 clang::Parser::ParseUsingDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (llvm/build/bin/clang+++0x6873406)
#25 0x000055a0b6b4e1e4 clang::Parser::ParseUsingDirectiveOrDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation&, clang::ParsedAttributes&) (llvm/build/bin/clang+++0x68721e4)
#26 0x000055a0b6bed4cb clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (llvm/build/bin/clang+++0x69114cb)
#27 0x000055a0b6bec560 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (llvm/build/bin/clang+++0x6910560)
#28 0x000055a0b6bebe26 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (llvm/build/bin/clang+++0x690fe26)
#29 0x000055a0b6b2a007 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (llvm/build/bin/clang+++0x684e007)
#30 0x000055a0b6c00364 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (llvm/build/bin/clang+++0x6924364)
#31 0x000055a0b6bfe7e6 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (llvm/build/bin/clang+++0x69227e6)
#32 0x000055a0b6b121ee clang::ParseAST(clang::Sema&, bool, bool) (llvm/build/bin/clang+++0x68361ee)
#33 0x000055a0b546c49d clang::FrontendAction::Execute() (llvm/build/bin/clang+++0x519049d)
#34 0x000055a0b53d449d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (llvm/build/bin/clang+++0x50f849d)
#35 0x000055a0b550888e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (llvm/build/bin/clang+++0x522c88e)
#36 0x000055a0b2f03071 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (llvm/build/bin/clang+++0x2c27071)
#37 0x000055a0b2eff3de ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#38 0x000055a0b51b5d29 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::$_0>(long) Job.cpp:0:0
#39 0x000055a0b46a7ef6 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (llvm/build/bin/clang+++0x43cbef6)
#40 0x000055a0b51b53c3 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (llvm/build/bin/clang+++0x4ed93c3)
#41 0x000055a0b517016d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (llvm/build/bin/clang+++0x4e9416d)
#42 0x000055a0b5170447 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (llvm/build/bin/clang+++0x4e94447)
#43 0x000055a0b5192879 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (llvm/build/bin/clang+++0x4eb6879)
#44 0x000055a0b2efe851 clang_main(int, char**, llvm::ToolContext const&) (llvm/build/bin/clang+++0x2c22851)
#45 0x000055a0b2f10092 main (llvm/build/bin/clang+++0x2c34092)
#46 0x00007f3cdd845cd0 (/usr/lib/libc.so.6+0x27cd0)
#47 0x00007f3cdd845d8a __libc_start_main (/usr/lib/libc.so.6+0x27d8a)
#48 0x000055a0b2efb7e5 _start (llvm/build/bin/clang+++0x2c1f7e5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 0b07b06effe5fdf779b75bb5ac6cf15e477cb0be)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: llvm/build/bin
clang++: note: diagnostic msg:
********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm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