Assertion `!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
https://godbolt.org/z/oKdv9b1zb
The testfile is very long, but creduce failed in my own environment. I used https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCXX/diagnose_if.cpp as the input.
It seems to be introduced since clang 14.0.0 on godbolt. It can be triggered only with the assertion build.
https://godbolt.org/z/7n6vfdTK1
```
fatal error: too many errors emitted, stopping now [-ferror-limit=]
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ExprConstant.cpp:22208: bool clang::Expr::EvaluateWithSubstitution(clang::APValue&, clang::ASTContext&, const clang::FunctionDecl*, llvm::ArrayRef, const clang::Expr*) 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++ -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 -fsyntax-only
1. :601:36: current parser token ';'
2. :593:1: parsing namespace 'initializer_lists'
3. :600:12: parsing function body 'initializer_lists::run'
4. :600:12: in compound statement ('{}')
#0 0x000000000453f658 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453f658)
#1 0x000000000453c484 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453c484)
#2 0x000000000453caa4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453caa4)
#3 0x0000000004479268 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x0000711fae242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x0000711fae2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x0000711fae242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x0000711fae2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x0000711fae22871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x0000711fae239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x0000000008297541 clang::Expr::EvaluateWithSubstitution(clang::APValue&, clang::ASTContext&, clang::FunctionDecl const*, llvm::ArrayRef, clang::Expr const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8297541)
#11 0x0000000007788419 clang::Sema::diagnoseArgDependentDiagnoseIfAttrs(clang::FunctionDecl const*, clang::Expr const*, llvm::ArrayRef, clang::SourceLocation)::'lambda'(clang::DiagnoseIfAttr const*)::operator()(clang::DiagnoseIfAttr const*) const SemaOverload.cpp:0:0
#12 0x00000000077aa67b bool diagnoseDiagnoseIfAttrsWith, clang::SourceLocation)::'lambda'(clang::DiagnoseIfAttr const*)>(clang::Sema&, clang::NamedDecl const*, bool, clang::SourceLocation, clang::Sema::diagnoseArgDependentDiagnoseIfAttrs(clang::FunctionDecl const*, clang::Expr const*, llvm::ArrayRef, clang::SourceLocation)::'lambda'(clang::DiagnoseIfAttr const*)&&) (.constprop.0) SemaOverload.cpp:0:0
#13 0x00000000077aa8a6 clang::Sema::diagnoseArgDependentDiagnoseIfAttrs(clang::FunctionDecl const*, clang::Expr const*, llvm::ArrayRef, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x77aa8a6)
#14 0x0000000007113ee5 clang::Sema::checkCall(clang::NamedDecl*, clang::FunctionProtoType const*, clang::Expr const*, llvm::ArrayRef, bool, clang::SourceLocation, clang::SourceRange, clang::VariadicCallType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7113ee5)
#15 0x00000000071163e9 clang::Sema::CheckConstructorCall(clang::FunctionDecl*, clang::QualType, llvm::ArrayRef, clang::FunctionProtoType const*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71163e9)
#16 0x00000000072f19ff clang::Sema::CompleteConstructorCall(clang::CXXConstructorDecl*, clang::QualType, llvm::MutableArrayRef, clang::SourceLocation, llvm::SmallVectorImpl&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72f19ff)
#17 0x00000000075605b7 PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#18 0x000000000756f5b1 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x756f5b1)
#19 0x00000000074d0239 clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74d0239)
#20 0x00000000074d0ba9 clang::Sema::ActOnCXXTypeConstructExpr(clang::OpaquePtr, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74d0ba9)
#21 0x0000000006f2dbe6 clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f2dbe6)
#22 0x0000000006f122db clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f122db)
#23 0x0000000006f12e37 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f12e37)
#24 0x0000000006f12ec9 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f12ec9)
#25 0x0000000006f17509 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f17509)
#26 0x0000000006f9ec89 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f9ec89)
#27 0x0000000006f960b4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f960b4)
#28 0x0000000006f96a99 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f96a99)
#29 0x0000000006f9f40e clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f9f40e)
#30 0x0000000006f9fc2a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f9fc2a)
#31 0x0000000006ea4123 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea4123)
#32 0x0000000006edae33 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+++0x6edae33)
#33 0x0000000006e976cb clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e976cb)
#34 0x0000000006e97ecf clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e97ecf)
#35 0x0000000006e9f951 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9f951)
#36 0x0000000006efaf75 clang::Parser::ParseInnerNamespace(llvm::SmallVector const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6efaf75)
#37 0x0000000006efdf69 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6efdf69)
#38 0x0000000006ee3a80 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ee3a80)
#39 0x0000000006e9f976 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9f976)
#40 0x0000000006ea0865 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea0865)
#41 0x0000000006e8174a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e8174a)
#42 0x000000000537f275 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x537f275)
#43 0x00000000052fddf8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52fddf8)
#44 0x000000000547bb4d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x547bb4d)
#45 0x0000000000df703b cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf703b)
#46 0x0000000000ded99a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#47 0x0000000000dedb1d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#48 0x00000000050c7189 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#49 0x00000000044796a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44796a4)
#50 0x00000000050c77b6 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#51 0x0000000005085e92 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5085e92)
#52 0x0000000005086e3e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5086e3e)
#53 0x000000000508eae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x508eae5)
#54 0x0000000000df33c4 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdf33c4)
#55 0x0000000000caa03a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcaa03a)
#56 0x0000711fae229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#57 0x0000711fae229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#58 0x0000000000ded435 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xded435)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
Contributor guide
Research direction
Start by reproducing the assertion with the Compiler Explorer links and the assertion-enabled Clang build, using clang/test/SemaCXX/diagnose_if.cpp as the reported input. Trace the call from SemaOverload.cpp into ExprConstant.cpp:22208 and reduce the triggering case if possible. Done means the input no longer reaches the failed assertion and a regression test covers the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100