<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61777>61777</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Class template with constrained NTTP nested in a class template crashes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:frontend,
concepts,
crash,
crash-on-valid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cjdb
</td>
</tr>
</table>
<pre>
The snippet below is from GCC's test `concepts-partial-spec9.C`, and is a minimal repro for an assertion failure. It may or may not be related to #61776.
```cpp
template <class> concept C = true;
template <class> struct O {
template <class, C auto> struct A { static const int i = 0; };
};
static_assert(O<void>::A<int, 0>::i == 0);
```
```
clang++: /root/llvm-project/clang/lib/AST/ExprConstant.cpp:15330: bool clang::Expr::EvaluateAsConstantExpr(clang::Expr::EvalResult&, const clang::ASTContext&, clang::Expr::ConstantExprKind) const: Assertion `!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <source>:6:35: current parser token 'i'
#0 0x000056060659438f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c7438f)
#1 0x00005606065920cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c720cc)
#2 0x00005606064df238 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f971486d420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f971433a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f9714319859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f9714319729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f971432afd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000560609ddbd37 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74bbd37)
#9 0x0000560608f20617 clang::ActionResult<clang::Expr*, true> calculateConstraintSatisfaction<calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::'lambda'(clang::Expr const*)>(clang::Sema&, clang::Expr const*, clang::ConstraintSatisfaction&, calculateConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, clang::SourceLocation, clang::MultiLevelTemplateArgumentList const&, clang::Expr const*, clang::ConstraintSatisfaction&)::'lambda'(clang::Expr const*)&&) SemaConcept.cpp:0:0
#10 0x0000560608f20ba2 CheckConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) SemaConcept.cpp:0:0
#11 0x0000560608f211c4 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66011c4)
#12 0x0000560608f269b3 clang::Sema::EnsureTemplateArgumentListConstraints(clang::TemplateDecl*, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66069b3)
#13 0x0000560609634c95 clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d14c95)
#14 0x0000560609637ac1 clang::Sema::CheckTemplateIdType(clang::TemplateName, clang::SourceLocation, clang::TemplateArgumentListInfo&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d17ac1)
#15 0x0000560608e0cc64 clang::Sema::ActOnCXXNestedNameSpecifier(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::OpaquePtr<clang::TemplateName>, clang::SourceLocation, clang::SourceLocation, llvm::MutableArrayRef<clang::ParsedTemplateArgument>, clang::SourceLocation, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64ecc64)
#16 0x0000560608cf856f clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&, clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool, clang::IdentifierInfo**, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63d856f)
#17 0x0000560608c7c55d clang::Parser::TryAnnotateTypeOrScopeToken(clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x635c55d)
#18 0x0000560608cdd5ea clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63bd5ea)
#19 0x0000560608ceb3e6 clang::Parser::ParseConstantExpressionInExprEvalContext(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63cb3e6)
#20 0x0000560608cc411e clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63a411e)
#21 0x0000560608cb4f10 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6394f10)
#22 0x0000560608c80ff3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6360ff3)
#23 0x0000560608c81f0d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6361f0d)
#24 0x0000560608c75dda clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6355dda)
#25 0x00005606077b4f78 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e94f78)
#26 0x00005606070198a9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46f98a9)
#27 0x0000560606f9ddd6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x467ddd6)
#28 0x00005606070fd537 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47dd537)
#29 0x0000560603b125a6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x11f25a6)
#30 0x0000560603b0e3ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000560606e060ad 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
#32 0x00005606064df720 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bbf720)
#33 0x0000560606e0696f 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
#34 0x0000560606dce1ac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44ae1ac)
#35 0x0000560606dcec4d 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+++0x44aec4d)
#36 0x0000560606dd68fd clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b68fd)
#37 0x0000560603b10a50 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x11f0a50)
#38 0x0000560603a1c4c5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10fc4c5)
#39 0x00007f971431b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#40 0x0000560603b090de _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x11e90de)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWsty2zizfhp6g5KKBHhdeKHI9hzPyUxyYtdf2alAAJQ5oQAeAHTst_-rQUoiqEucjDWbqUrKFNjoy9eN7gYIaky9lkJcB8mHILm5op19Uvqa_cXLq1Lx1-vHJ4GMrNtWWFSKRn1HtUGVVhv023IZ4MwgK4xFQRoyJZlorZm1VNuaNjPTClbMl0EaBniJqOQwlaJNLesNbZAWrVaoUhpRiagxQttaSVTRuum0mKN7izb0FS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