[clang] Assertion `!Init->isValueDependent()' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
We have the following test in clang/test/SemaCXX/lambda-unevaluated.cpp:
```cpp
namespace lambda_in_trailing_decltype {
auto x = ([](auto) -> decltype([] {}()) {}(0), 2);
}
```
https://github.com/llvm/llvm-project/blob/c78c9004a7f82de1c9d9e7489651e4d6e9320e01/clang/test/SemaCXX/lambda-unevaluated.cpp#L150
Compiling this test with clang-trunk and clang-22 results in a crash:
https://godbolt.org/z/Pq8MbdGvb
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/Decl.cpp:2564: clang::APValue* clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl >&, bool) const: Assertion `!Init->isValueDependent()' 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
1. parser at end of file
2. :1:11: LLVM IR generation of declaration 'lambda_in_trailing_decltype'
3. :2:6: Generating code for declaration 'lambda_in_trailing_decltype::x'
#0 0x00000000044b7d78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b7d78)
#1 0x00000000044b4bb4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b4bb4)
#2 0x00000000044b51d4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b51d4)
#3 0x00000000043f34c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x000076e82be42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x000076e82be969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x000076e82be42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x000076e82be287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x000076e82be2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x000076e82be39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x0000000007fc7de3 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7fc7de3)
#11 0x0000000007fc7e6a clang::VarDecl::evaluateValue() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7fc7e6a)
#12 0x0000000004a05850 clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a05850)
#13 0x0000000004a05b8e clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a05b8e)
#14 0x0000000004c0feaf clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c0feaf)
#15 0x0000000004c3aa21 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c3aa21)
#16 0x0000000004c3b273 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c3b273)
#17 0x0000000004c4735b clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#18 0x0000000004c4833f clang::CodeGen::CodeGenModule::EmitDeclContext(clang::DeclContext const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c4833f)
#19 0x0000000004c478b9 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#20 0x0000000004fc2449 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#21 0x0000000004fb2894 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fb2894)
#22 0x0000000006dbc564 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dbc564)
#23 0x0000000004fc01e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fc01e8)
#24 0x00000000052f0b48 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52f0b48)
#25 0x000000000526ff60 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x526ff60)
#26 0x00000000053ee5dd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53ee5dd)
#27 0x0000000000e136bb cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe136bb)
#28 0x0000000000e0a06a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#29 0x0000000000e0a1ed int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#30 0x00000000050312c9 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x00000000043f3904 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43f3904)
#32 0x0000000005031916 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x0000000004fef942 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fef942)
#34 0x0000000004ff08ee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ff08ee)
#35 0x0000000004ff8515 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ff8515)
#36 0x0000000000e0fa94 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe0fa94)
#37 0x0000000000cb26ca main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb26ca)
#38 0x000076e82be29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x000076e82be29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 0x0000000000e09b05 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe09b05)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
Contributor guide
Assessment
This issue has not been assessed yet.