Issue 202957
Summary [clang] Assertion `Depth >= 0 && "Depth must be non-negative"'`failed during template instantiation
Labels clang
Assignees
Reporter hongtaihu
    
This input is generated by a fuzzer.
Seems to be trunk-only.

use
```
-std=c++20 -fsyntax-only
```

source code
```cxx
// ensure we properly diagnose when "D" is false.
namespace DIsFalse {
template<auto Q> concept C = requires { Q.template operator()<float>(); };
template<class> concept D = false;
static_assert(C<[]<D>{}>);
// expected-error@-1{{static assertion failed}}
// expected-note@-2{{does not satisfy 'C'}}
// expected-note@-5{{because 'Q.template operator()<float>()' would be invalid: no matching member function for call to 'operator()'}}
}

```

stacktrace
```
clang++: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument]
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ASTContext.cpp:6009: clang::QualType clang::ASTContext::getTemplateTypeParmType(int, int, bool, clang::TemplateTypeParmDecl*) const: Assertion `Depth >= 0 && "Depth must be non-negative"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
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 -fsyntax-only <source>
1.	<source>:5:25: current parser token ')'
2.	<source>:2:1: parsing namespace 'DIsFalse'
 #0 0x0000000004385c18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4385c18)
 #1 0x0000000004382a54 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4382a54)
 #2 0x0000000004383074 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4383074)
 #3 0x00000000042bf2f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007ece6f445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007ece6f49eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #6 0x00007ece6f44527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x00007ece6f4288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x00007ece6f42881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x00007ece6f43b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000007bf2633 clang::ASTContext::getTemplateTypeParmType(int, int, bool, clang::TemplateTypeParmDecl*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7bf2633)
#11 0x0000000007e96f03 clang::TemplateTypeParmDecl::Create(clang::ASTContext const&, clang::DeclContext*, clang::SourceLocation, clang::SourceLocation, int, int, clang::IdentifierInfo*, bool, bool, bool, clang::OptionalUnsigned<unsigned int>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e96f03)
#12 0x0000000007824bf7 clang::TemplateDeclInstantiator::VisitTemplateTypeParmDecl(clang::TemplateTypeParmDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7824bf7)
#13 0x000000000787c4b0 clang::TemplateDeclInstantiator::SubstTemplateParams(clang::TemplateParameterList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x787c4b0)
#14 0x0000000007797151 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*) SemaTemplateInstantiate.cpp:0:0
#15 0x00000000077991cc clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#16 0x00000000077b0a64 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
#17 0x00000000077b13f2 (anonymous namespace)::TemplateInstantiator::TransformTemplateArgument(clang::TemplateArgumentLoc const&, clang::TemplateArgumentLoc&, bool) SemaTemplateInstantiate.cpp:0:0
#18 0x00000000077b2ec7 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
#19 0x00000000077b3554 clang::Sema::SubstTemplateArguments(llvm::ArrayRef<clang::TemplateArgumentLoc>, clang::MultiLevelTemplateArgumentList const&, clang::TemplateArgumentListInfo&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x77b3554)
#20 0x0000000006f890ac (anonymous namespace)::ConstraintSatisfactionChecker::Evaluate(clang::ConceptIdConstraint const&, clang::MultiLevelTemplateArgumentList const&) SemaConcept.cpp:0:0
#21 0x0000000006f8afd9 CheckConstraintSatisfaction(clang::Sema&, clang::NamedDecl const*, llvm::ArrayRef<clang::AssociatedConstraint>, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&, clang::Expr**, clang::ConceptReference const*) SemaConcept.cpp:0:0
#22 0x0000000006f8b8fd clang::Sema::CheckConstraintSatisfaction(llvm::PointerUnion<clang::NamedDecl const*, clang::concepts::NestedRequirement const*>, llvm::ArrayRef<clang::AssociatedConstraint>, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&, clang::ConceptReference const*, clang::Expr**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f8b8fd)
#23 0x0000000007668e07 clang::Sema::CheckConceptTemplateId(clang::CXXScopeSpec const&, clang::SourceLocation, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::TemplateDecl*, clang::TemplateArgumentListInfo const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7668e07)
#24 0x000000000767062d clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, clang::SourceLocation, clang::LookupResult&, bool, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x767062d)
#25 0x000000000719f508 clang::Sema::ActOnIdExpression(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool, bool, clang::CorrectionCandidateCallback*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x719f508)
#26 0x0000000006cd0ef1 clang::Parser::tryParseCXXIdExpression(clang::CXXScopeSpec&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cd0ef1)
#27 0x0000000006cd118e clang::Parser::ParseCXXIdExpression(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cd118e)
#28 0x0000000006cb5324 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cb5324)
#29 0x0000000006cb4c00 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cb4c00)
#30 0x0000000006cc1afe clang::Parser::ParseConstantExpressionInExprEvalContext(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cc1afe)
#31 0x0000000006c991a6 clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c991a6)
#32 0x0000000006c87a46 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c87a46)
#33 0x0000000006c435f6 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c435f6)
#34 0x0000000006c9ed35 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c9ed35)
#35 0x0000000006ca1d29 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ca1d29)
#36 0x0000000006c87b00 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c87b00)
#37 0x0000000006c435f6 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c435f6)
#38 0x0000000006c444e5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c444e5)
#39 0x0000000006c448d0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c448d0)
#40 0x0000000006c25393 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c25393)
#41 0x00000000051a9458 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51a9458)
#42 0x0000000005126c9d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5126c9d)
#43 0x00000000052a803d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52a803d)
#44 0x0000000000e21efc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe21efc)
#45 0x0000000000e18b9a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#46 0x0000000000e18d1d 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
#47 0x0000000004ee4b39 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
#48 0x00000000042bf734 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42bf734)
#49 0x0000000004ee5186 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
#50 0x0000000004ea2102 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ea2102)
#51 0x0000000004ea30ae 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+++0x4ea30ae)
#52 0x0000000004eab3a5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4eab3a5)
#53 0x0000000000e1e432 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe1e432)
#54 0x0000000000cc210a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc210a)
#55 0x00007ece6f42a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#56 0x00007ece6f42a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#57 0x0000000000e18545 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe18545)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to