Clang accepts indirectly invoking a consteval function outside of a manifestly constant evaluated context
Open
clang:frontend
consteval
crash-on-invalid
regression:21
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
https://godbolt.org/z/7rG65c13e
The following code is accepted by clang 22.1.0:
```cpp
consteval void f(int) {}
int main() {
auto g = []() consteval {
return [](int x) {
f(x);
};
}();
int x = 42;
g(x);
}
```
A PLT call to the wrapped consteval function (`f`) is emitted which invokes a linker error.
Contributor guide
Research direction
Start by reproducing the Godbolt example with Clang 22.1.0, focusing on the consteval lambda and its indirect call to f. Trace how Clang handles this invocation outside a manifestly constant-evaluated context, and verify that the fix prevents the emitted PLT call and resulting linker error.
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
- 48/100