Issue |
150851
|
Summary |
Returning `static constexpr` variables by reference from `consteval` functions is completely broken
|
Labels |
new issue
|
Assignees |
|
Reporter |
HolyBlackCat
|
Here's a reproducer:
```cpp
#include <iostream>
consteval const auto &bar()
{
static constexpr auto ret = 42;
return ret;
}
static_assert(bar() == 42);
int main()
{
std::cout << bar() << '\n'; // 0
}
```
Notice that the `static_assert` says `bar() == 42`, but if you try to print `bar()` with `cout`, it prints `0`.
Tested on Clang 20 and trunk.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs