Issue |
135281
|
Summary |
`consteval` constructor cannot store `this` inside object
|
Labels |
new issue
|
Assignees |
|
Reporter |
snarkmaster
|
Unlike GCC & MSVC, Clang refuses to compile this https://godbolt.org/z/WYr58Ge9s --
```cpp
struct B {
const void* immortal_;
consteval B() : immortal_{this} {}
};
constexpr static B b;
```
The error suggests that the frontend wrongly thinks that `this` is a pointer to a temporary:
```
<source>:6:20: error: call to consteval function 'B::B' is not a constant _expression_
6 | constexpr static B b;
| ^
<source>:6:20: note: pointer to temporary is not a constant _expression_
<source>:6:20: note: temporary created here
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs