<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62944>62944</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Example from C++ standard is rejected as part of constant expression
</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>
[OK example](https://timsong-cpp.github.io/cppwp/n4868/class.mem.general#25) from C++ standard is rejected by Clang if it is evaluated as constant expression:
```
struct T1 { int a, b; };
struct T2 { int c; double d; };
union U { T1 t1; T2 t2; };
constexpr int f() {
U u = { { 1, 2 } }; // active member is t1
return u.t2.c; // OK, as if u.t1.a were nominated
}
constexpr int x = f();
```
with the error:
```
read of member 't2' of union with active member 't1' is not allowed in a constant expression
```
Other compilers reject it as well (https://gcc.godbolt.org/z/YTds3Grd5), but since Clang is typically most standard conforming, I decided to ask you first.
Related discussion: https://stackoverflow.com/q/76323477/7325599
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE1v4zYQ_TX0ZRBBGlmSfdBhHVdFsYcARfbQI0WOZHYpUiVHcdxfX1C2mybNAmv4S-KbxzePTyNjNKMjakV1ENVxIxc--dB2pMOm9_qS7j99BXqV02xJVEeBuxPzHEX5RWAnsGMzRe_GBzXP2Wj4tPSZ8QI7Nc_nWWDntrt6l66tjDGbaMpGchSkFVhiJXAPQ_ATPAo8CDxAZOm0DBpMhEB_kmLS0F_g0Uo3ghnAcFqiF2kXmdZkBOVdKmOg1zlQjMa7JC8_ivyLqPPbe72MHBbF8FyAaA5gHIMU-Ai9KA8gmqMoD-9x-C9OJYj2S28J9Ef44ox38G0FPxfARQI8IzB-RF6_V8VJ7Uo9CNwlI0RzAwF8gwVEeVwJ06dIKpOY440NAK7-g1RsXggmmnoKyRsu7iyBeAkOlowxU9ei9XWrfPqaWGVMti4ZF5mEMwUC5yfjkrk3yc3xx9pfV5m3Dt66fO_62fAJ-ERAIfjwo7MJJDX44d6JwIZRYJNuXf1dad63m0BFApkIzjNIa_2ZNBgH8tNcfLbxE58ogPLTbCyFe-5S0mSEM1kL_0v9qFQ2et17y5kPo8Dub4HdH886lr8GnWK9xmphiMYpusc3Al9mo6S1F5h85Le4K-8GHybjxlT4G2hSRpMG9iDjd7j4BQYTImf_PYrfya7PgDZRLffcw3ulkaX67l8oDNafM-Ungd1fArumLrHcNk36W2JV7fcb3ZZ6X-7lhtqi3lX5tm729ebU0h6rJq_LnVRFXsuh6mWlUNXFvt42NNQb02KOZV5hhXlZFnVGVV4RFfVupyuqdoPY5jRJYzNrX6Zk2MbEuFBb43673VjZk43rCEJ0dIZ1USCmiRTaVPPQL2MU29yayPGNhQ1ban-5TqefGCQywiwDp0h9Eo7NEmz74ZyvE-1qW9r29vMwB584BXar2CiwW5v5JwAA__8QGZ1_">