efriedma-quic wrote:

The primary problem with allowing flexible arrays alone in structs/unions is 
that you end up with a zero-size type.  This leads to weird semantic issues 
because standard C/C++ doesn't have any provision for zero-size types: pointer 
arithmetic, struct layout, and initialization aren't well-defined when 
zero-size types are involved.  Because we support zero-length arrays/empty 
structs as an extension, we have some solution for some of these cases, but 
some of the edge cases just explode.  (And there's no guidance from the 
standard because the standard doesn't allow this in the first place.)

Something like `union U { int x, y[]; };` doesn't run into those issues, 
though; the expected semantics are pretty unambigious.

https://github.com/llvm/llvm-project/pull/84428
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to