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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 06:52:02 PDT 2024


erichkeane 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?

I don't see this as being 'accidental', see the GCC bug, Martin makes good points: with the `0`, this is a valid extension point, without, it is not.

It seems that Martin @ GCC isn't willing to make this change, or at least isn't compelled either, so I'd prefer whatever we do to be in lockstep with them, if we choose to do anything.

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


More information about the cfe-commits mailing list