[clang] [Clang][Sema]: Allow flexible arrays in unions and alone in structs (PR #84428)

Kees Cook via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 9 18:23:08 PST 2024


kees wrote:

> Left my comment on the main list, but I don't see this as a well motivated change, and even if GCC supported it, it would still be a very difficult to motivate extension without massive historical workloads already using it.

This is needed by the Linux kernel, and is in active use. Directly converting from [0] to [] isn't possible due to all the places flex arrays are used in unions. Linux is working around this by tricking the syntax checker currently, which needlessly complicates things. There are currently over 200 separate unions using the work-around.

So, this fixes the accidental lack of the existing [0] extensions not being directly applied to [], and doesn't cause problems for any other users. What solution should Linux use if not fixing this directly nor providing something like -fflex-array-extensions?



https://github.com/llvm/llvm-project/pull/84428


More information about the cfe-commits mailing list