<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61398>61398</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Anonymous union cannot be declared as constexpr
</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>
The following code
```
constexpr static union {
int i = 1;
} u; //ok everywhere
constexpr static union {
int k = 1;
}; //error in Clang
```
is fully accepted in GCC, and the first part `u.i` is accepted in Clang. But for the second part the error is shown:
```
union cannot be marked constexpr
```
Online demo: https://gcc.godbolt.org/z/Wd4WWq5Pn
It is either wrong compiler rejection (if GCC is right) or the error message is inexact, considering that the first `constexpr union` is accepted.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk8uOmzAUhp_msDkaZMwlsGCRi6i6aheVZu3gA7hj7NQ2k0mfvjJJm-k0m0pIyPa5_d9vC-_VaIhaKHdQHhKxhMm6tiPpkqOVl_bbRDhYre1ZmRF7KwnYAdgWKnb71mVvjQ_0dnLogwiqx8UoaxA2u-s5IqIyARVCfsAM8ts-bA64QL5D4B3wzr4gvZK7nCdyvxv9V_2Xf-vfq5Nz1qEyuNfCjA91KI_DovUFRd_TKZCM4Z_2e-B7FEZiiDiU8wFPwgWEii2pgoqh8n-lrB1S3C0BB-vWNE-9NfKaF9e3aTz6yZ4N5NuHA1119sIYG_BIOAv3QhL_8HiY9MVoZQglzRbyLU4hnHxssFIY-z4drTxaHVLrRuDdT-Ddsyyen3-UX8176p9DnI9UmMjh2dn1Bswnpcmho-_Uh9UEXqshQorBTo1TAN7gTfVV5Uzei5FigDL0JvoQgUYRSpKLNytMIryjCxW7W74y-AA5TWSbyyZvREJtVm3qTc2KukmmVvKh4k1dNYwPleAk81IOpcybJqNMZiJRLWc8Z3lWsE1ZFE3aFIUUDSvzqqK6rgYoGM1C6VTr1zkySpT3C7VVljd1osWRtF8fDOeGzrgeAufx_bg25jwdl9FDwbTywd-rBBU0tVtjzWW2i8eP3krqtXAkUfi7wcnidPvBQRWm5Zj2dgbexeq339PJ2WgK8G6dyQPv1pl_BQAA__9B3zjQ">