<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/135601>135601</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
"uninitialized when used here" warning in successful constant expression 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>
This program:
```
#include <memory>
struct A {
int i, j;
constexpr A() : i((std::construct_at(&j, 2), j-1)) {}
};
constexpr A a{};
static_assert(a.i == 1);
static_assert(a.j == 2);
```
is accepted in GCC and MSVC.
Clang also accepts it with the warning:
```
<source>:5:50: warning: field 'j' is uninitialized when used here [-Wuninitialized]
5 | constexpr A() : i((std::construct_at(&j, 2), j-1)) {}
| ^
```
Online demo: https://gcc.godbolt.org/z/YzEoPPj96
This looks contradicting, since reading of uninitialized values in constant expressions must result in hard fail. Or the program is ok, and the diagnostic is simply wrong.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VMFu4zYQ_ZrxZRCDJi3JOuig2HFPxS7QokVPC5ocS_RSpMGh4iZfX1Bxuttg21sBGzb0Ht-beTOiZnZDIOqgeoTqsNJzHmPqjmTT6hTtS_fr6BivKQ5JT6B6ED3U4v4RPUjlgvGzJQS1n2iK6QXUU0FEzznNJmOP0DyC6BERXcjoQO7xAur9mYmBM_15TdiD3IFsEVRfWDuQO862uKp-YRW9LzovUH0pOhJku-g9bJZ_7WLWHEoFzeHN5DsD1Hd4ATjr7MwXzUypiOq1Q1AHUAdc1P6FdHknyb9J32fiGLUxdM1k0QX8ab9HHSz-_Mtv-_VbMHuvw4Dac7wzGV3Gm8sj5pHwplNwYfhB2mrPcU6GSsSqr8pXlLC-ncCzI28RZHMB2aBjnIMLLjvt3StZvI0UcGayOFIihOrx4fd_MKA63OdSITR7_D8ntIgvLlA9fej1U_AuEFqaYjEbc75y8ZFHkMfBmPUQ7Sn6vI5pAHl8BXn84_Upfv58aeu3lJfN9TF-5dJATto6k0tKco_sgiFMpK0LA8bzh5SetZ-Jy_SWpnTIWNonZhcD4zRzxkQ8-1w4o04Wz9r5NX5KywTv70uJP34tfmUBCmCdHkLk7EzB2E1X_4K3FMOwXtlO2Va1ekXdptlua7mpq3Y1doLMWdWn5myEIKKdbDdnTVZsddMoJXYr10khK7HdbEUrGtWuldrWTXMWVX3ekTzVsBU0lfq8f55KYCvHPFO3UVUtNiuvT-R5uQGkDHTDBQUpy4WQunLo4TQPDFvhHWf-JpNd9tSBlP-1ZCDl-4KWtHg2hpjPs_9RuEgle51dDKs5-e7D3F0e59PaxAnksVRx_3m4pnghk0Eel9oZ5PHe3HMn_woAAP__7jJ_hg">