<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55112>55112</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Uninitialized field read is accepted in constant evaluation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fedr
</td>
</tr>
</table>
<pre>
In this program:
```
#include <memory>
#include <iostream>
struct A {
int x = x;
};
constexpr int foo()
{
A a{1};
std::construct_at<A>(&a);
return a.x;
}
constexpr int v = foo();
int main() {
std::cout << v;
}
```
Clang issues
```
warning: field 'x' is uninitialized when used here [-Wuninitialized]
int x = x;
```
but still accepts the program, which prints `0`. But I think the program with uninitialized field read in constant evaluation must be rejected.
Or it shall print `1` as GCC does. Demo: https://gcc.godbolt.org/z/8Ejz9YK86
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFUslu2zAQ_RrqMoggUZt10MGxkyLooaei6KmgpInElCYNkrKdfH2HUlLbQYIIJEXO8ubN0pr-uXnQ4EfpYG_NYMWOZWuWbFmyZmXyupYnz6Tu1NQjsGyzw52xzyy7-0gpjfMWA9Sbej5JOHUe1sCq20UC9Ent4UReWzix7FXOqu35Pp-d0c7jaW9n-0djGF8xXr-ZX-CtQdA7vYQIYuf7kFm2IAUif4QnrutAMmCVIuBdulj0k9Ug4mtin7I6zFmcuV1nECx2QupFeV2DC3KTDxWkBYcPol63ZKOEHkA6N6GDDy2OwmqpB0KGR4mqB8arE21ygok00kuh5Av2cBxRw-ToNqKlLha3N7-uLFix_aJp16FbysR5qRSIrsO9dzRl-H_I-IYiym4kAWER-zIJrjHckttDGEj999IBjtKP7ygvGdGg9cQH5l4I4oUHoSbhpdGwm5yHFsnmCTuPfXzZkB_UNaI4CqI4swgkUtogHHzbbKA36GLY0qSH-o3e713oEr-nNXRdPJi-NcrHxg4keaG9unt6qX9_X5VR32R9ndUi8tIrbH5-Sty9lgc_SyKarGreBadaTG3cGarjvVKHt98NFSskSs9lKOhSFGnKo7FJu7rKc55XvOZpsmoxSfO043mZJ1ldFBgp0aJyDTWeca7xuMwV3anxkWx4wnmS8zItiiJbxTkv0qTkXSVQVNljz_IEabpVHHiEikS2mSm10-BIqaTz7qwUzslBI87hCF9MfjS2ucfeRnPcZub9D82wXx0">