<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95854>95854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang incorrectly considers a class with an anonymous union member to not be const-default-constructible even if a union member has a default member initializer
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++11,
clang:frontend,
rejects-valid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zygoloid
</td>
</tr>
</table>
<pre>
Testcase:
```c++
struct A {
union {
int n = 0;
int m;
};
};
const A a;
```
This is valid, but Clang rejects:
```console
<source>:7:9: error: default initialization of an object of const type 'const A' without a user-provided default constructor
```
(Clang accepts if `m` is removed.) See https://eel.is/c++draft/dcl.init#general-8.3 -- because `n` has an initializer, the entire anonymous union is treated as initialized.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsk-2OuygUxq_m-OVEo2B9-eCH_tvtDezcAMKxskFoALvpXP0G63Y6k0lIhAfx8DznpwhBXy3RAIc_cDhnYo2z88Pn4-qM0yobnXoMHxSiFIGAH6E8Q3mEpnwOCexPGpsaol9lxCNCuyuIq9XOvguI2ka0CPyMJfAf-vKmQHt-rd7n0tmQqoiv3f-v81x-zDqgDngXRitgJxzXiCcj7BU9_UMyhl-MOBucoV3lp-BWLwn4X8CPLfBjD_yI5L3zaaJoEquJqK2OWhj9KWKy6SYUFt2YaqTF86bxcSME1u73BtbivzrObo0ocA3k85t3d61Ivb67vZrCdP5Xh8C6px8hJd1iQD0hNOUCTZmMe1rcnVQBrMe_iXCO8bZ5ZhdgFyJT6ADssjdPeTFFYBclTZEMAeNXsuSFybuCY57jSFKsgVIJm0rMIiSjL_fkU8pxJiQbtScU1tnH4taw918HjJ5EJIUivJ1TRaYGrnrei4yGqq26pil7xrN5qDoqpRITa5VsuratRVWJcpoOpWzbuu4yPbCS1WVTtayqu5oXI6P60JejVKo_qIZDXdIitCmMuS-F89dMh7DS0B-6Q50ZMZIJG_aM7UlUFTAG7JSUFC_w4-SdjWTVa2MnKN_hYumn8UMqkY_rNUBdGh1i-CoadTQ0PNulrXTek4zmsfVYK_IBBUojQtioSLn-TG-hZSSP0aF1EUd64pHvsOQvWPRoCOlONuEgvh_eWvbiaxffGpit3gzfObnqOK9jId0C7JLs7I-Ea8oA2GULNKH0zPQ-sP8CAAD__z-mWY4">