[clang] [Clang][Sema]: Allow flexible arrays in unions and alone in structs (PR #84428)
Nick Desaulniers via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 11 10:38:40 PDT 2024
nickdesaulniers wrote:
But then we (and GCC and MSVC) support the `[0]` extension syntax. So it's not like codegen is impossible.
https://godbolt.org/z/PGa9KWGxq
```c
union foo {
int a;
int b[]; // error: flexible array member 'b' in a union is not allowed
};
union bar {
int a;
int b[0]; // works just fine!
};
```
So to me, it seems like the standard can be amended to add the "or unions too" and already 3 implementations could generate valid code (GCC and clang would both need their semantic analyses relaxed here, but their codegen seems to work for the `[0]` extension already).
https://github.com/llvm/llvm-project/pull/84428
More information about the cfe-commits
mailing list