llvm / llvm/llvm-project

Clang assertions build crashes while compiling a small C++2b testcase using `consteval` + generic lambda + nested `decltype` return type.

Open
#188,159 4 comments 0 reactions 0 assignees View on GitHub
clang:frontend consteval crash-on-valid generated by fuzzer lambda
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

FUZZ Generate:

Assertion `!T->isDependentType() && "should not see dependent types here"` failed.

in `ASTContext::getTypeInfoImpl`, with stack frames through `ItaniumRecordLayoutBuilder::LayoutField` and `Sema::CheckFunctionCall`.
This may be related to existing dependent-type assertion issues, but this reproducer is small and stable on my setup.

---
### Reproducer
```cpp
#include
template
consteval auto matches(T t) {
return [](auto u) -> decltype([u]() {}()) {}(t);
}
int main() {
matches(0);
return 0;
}
```

```
Command
/root/autodl-tmp/RL-LLMfuzzer/toolchains/clang-assertions/install/bin/clang++ \
-std=c++2b -O0 -c probe_02_consteval_lambda_decltype.cpp -o /tmp/probe_02.o
Also reproduces with:

.../clang++ -std=c++2b -O2 -c probe_02_consteval_lambda_decltype.cpp -o /tmp/probe_02.o
.../clang++ -std=c++2b -O0 -emit-llvm -S -c probe_02_consteval_lambda_decltype.cpp -o /tmp/probe_02.ll
Observed crash (excerpt)
clang++: .../clang/AST/TypeNodes.inc:79:
clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const:
Assertion `!T->isDependentType() && "should not see dependent types here"' failed.
Stack dump:
...
#9 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const
#13 (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutField(...)
#19 clang::Sema::CheckArgAlignment(...)
#20 clang::Sema::CheckFunctionCall(...)
#21 clang::Sema::BuildCallToObjectOfClassType(...)
Environment
Clang: assertions build
Version: clang version 20.1.0
Target: x86_64-unknown-linux-gnu
OS: Linux (Ubuntu 22.04 container)
Notes
On Ubuntu system clang++ 14 (non-assertions), this source produces a normal diagnostic rather than an assertion crash.
```

Potentially related issues (not sure if same root cause):
- https://github.com/llvm/llvm-project/issues/159505
- https://github.com/llvm/llvm-project/issues/91566
- https://github.com/llvm/llvm-project/issues/89013

Contributor guide

Open the contributing guide

Research direction

Start by compiling the supplied reproducer with the listed Clang assertions-build commands and inspect the assertion in clang/AST/TypeNodes.inc:79. Trace the mentioned ASTContext::getTypeInfoImpl, ItaniumRecordLayoutBuilder::LayoutField, and Sema call-checking frames, then compare behavior with the related issues. Done means the reproducer no longer crashes and produces a normal diagnostic or otherwise handles the case safely.

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
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.