Issue 151769
Summary New C23 typeof() cannot be used in a `union`.
Labels new issue
Assignees
Reporter g-berthiaume
    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
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to