<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/143689>143689</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Uninitialized `constinit struct S` is rejected
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/b4E6zYGPG
```cpp
struct S { int x; };
constinit S x;
```
Clang rejects this, GCC accepts. I believe Clang is wrong:
```
<source>:3:13: error: variable does not have a constant initializer
3 | constinit S x;
| ^
<source>:3:1: note: required by 'constinit' specifier here
3 | constinit S x;
| ^~~~~~~~~
<source>:3:13: note: subobject 'x' is not initialized
3 | constinit S x;
| ^
<source>:1:16: note: subobject declared here
1 | struct S { int x; };
|
```
https://eel.is/c++draft/dcl.constinit specifies that the program is ill-formed if `x` has dynamic initialization.
There is obviously no dynamic initialization happening here, so this error makes no sense.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVE2PpDYQ_TXFpTQIbNpMHzjQvcMot0hJDjnauBqcuG1im56PQ357ZLp3Z3Y1m2QthBGuj1evnkvGaCZH1MHuALtPhVzT7EP3YCK5J3mhQnn90s0pLRF4D2wANkxeK29T6cMEbHgFNqjmQbz-_vjzI1Q9iOr6jMsCVR9TWMeEvyC0BzQu4TPwA0L7CfgBqn70LibjTLZ4vv76EgCq_milmzDQHzSmiGk2EdgRH49HlONIS4ol_oSKrKEL4dXYRHwK3k0Z7tfBgB-jX8NIwB-A9xx4X-cXUgg-5I-LDEYqS6g9RXQ-4SwvhBI3mNIlzFCNtOaVAlQ9IiJHaI_4QR24rXwIu4fvpM9JnU-U90B_rSaQRvWCwNovEYG1GBcazclQwJkC_VDmv2_r3wj4DCGuyqvMdQbwnBObKw1vZev_n_z9-pCCXH4tPgagabQys_Gu4HoL-x-KyjbfNP5r-RLZMutoGIEdgB10kKcEbNCjLd_q-cx4Vp1MmGbCJfgpyHPmxFh7d_LhTBrNCUFUzyAqnGVE_eLk2YxvjMlkvCszoqr_NReT_b26GL9G-4LOf8cFZ7ks5IybrhSwI0a_XYGrXvEs_9xEipFcpLLQHdd7vpcFdXXb7EXDayGKuTvxRjPWqJYazdWOC0V1q4W4b2tRMdkWpmMV21Wirut6t2eiJCGqke_vmaybXasImorO0tjS2ss5X_vCxLhSVzdc3O8LKxXZuE0Qxhw94XYKjOWBErrsdKfWKUJTWRNTfAuTTLLU_ebeySuT-a4Lt15ndk28DQLSxRrst0PJpHlV5ejPwIac4LbdLcFnJ2DDBis3_ob70rF_AgAA__9NN4k9">