<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151769>151769</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
New C23 typeof() cannot be used in a `union`.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
g-berthiaume
</td>
</tr>
</table>
<pre>
Hi,
I just encountered what seems to be the same problem as https://github.com/llvm/llvm-project/issues/25689, but with C23 `typeof()` instead of the intrinsics `__typeof__()`.
Let me know if this issue is redundant.
## How to reproduce:
```c
#include <stdlib.h>
int main(void)
{
int x = 3;
struct { typeof((int){x}) y; };
return 0;
}
```
Compile with
```
clang -std=c23 main.c -o main
.\main.c:8:25: error: initializer element is not a compile-time constant
8 | __typeof__((int){x}) y;
| ^~~
1 error generated.
```
The error has been reproduced on Windows:
```
clang version 20.1.8
Target: x86_64-pc-windows-msvc
Thread model: posix
```
The error has been reproduced on Linux (Ubuntu WSL):
```
Ubuntu clang version 18.1.8 (++20240731024944+3b5b5c1ec4a3-1~exp1~20240731145000.144)
Target: x86_64-pc-linux-gnu
Thread model: posix
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVMGO2zYQ_ZrxZWCBGkqWdNDB9maRAote2iLHBUXNWkwl0iCptbeH_faCkjfZJikQRBAggnxDvvc4eioEc7LMLZQHKO82ao6D8-1p27GPg1HzxJvO9S_tRwN0BLEHsf8NP88hIlvtZhvZc4-XQUUMzFPA6LBjjANjUBPj2btu5AlVwCHGcwC5B7oHuj-ZOMxdpt0EdD-Oz2-f7dm7z6wj0L0JYeYAdE_lrm6AjtjNES8mDngkibAT8eXM7gmoBmpgJ9DYEFn16J4WBsZGb2wwOiTw4-MKf3z8UpCtih444sT4t3UXNKnUBFwORxPQcz_bXtl4AwNJIIkf3SVp9Xz2rp81g9zjDbAT66tXtLF6nHtGkMcQ-9F02QDyw4o1NuKkjAWqn53pEyuxh-oAYo-ISQBeEeQdSpBvkyH6WUeE6oDv9NfGxlReHa5Q3QE1-ALygGn8pdJznL1Fsc6kpXdsV0JHN53NyIvL36zqUdkTbkPsQd5pkgvxTOPWrRLEPoPyuE6C3Ncg91QmW9h759PAWBONGs0_7JFHntjG5LB1ERXq9eRtNBOjdjZEZeONeI1QHfHt-eYif6z8VolLJZQfXl9B7POVC57YsleR--x7B_4c-IYaVMCO2X695B6dxU_G9u6ydPKPDHpmH4yzSCLLszptqPyJY9J_rXePu2J71tvLusd2Cs96OdOntp1cz2MCnl0w11-g9mDsfEWg-q9utnHGT388JGe-Y3pb_i_hvE6EcfH0AHQgQYWoZC6oaIoC6CC7sit1zrpQcpu_8vWcv76B8qIUQmR5Ajb_I3pM7LYnO_-84k3fyr6Rjdpwm1dlIWpRFrQZ2o50JQoldk1BRfVEesedbIpS9FXxREW3MS0JKkUtchKyLCijptFV1ZdVVamaWEIheFJmzFLqZM6fNssv3-ZlXu2azag6HsOSi0SWL2sgAFGKSd8uUdXNpwCFGE2I4es20cSR29_5sqTU-4hCrWxq9o5xDtyjsahSMs3WOJviaDP7sf31nLxRf27p3wAAAP__EDa9UA">