[PATCH] D114080: [SYCL] Diagnose uses of zero length arrays

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 17 05:53:07 PST 2021


aaron.ballman added a comment.

In D114080#3137462 <https://reviews.llvm.org/D114080#3137462>, @Naghasan wrote:

> right, TIL `sizeof (ContainsArr)` is 0 according to clang. I can see trouble arising.
>
> @aaron.ballman maybe you know better, is that intended for the extension ?

I don't *know*, but I have two educated guesses that it is intended. GCC compatibility (GCC also has this behavior) and the relationship between zero-sized array members and flexible array members. Clang allows a flexible array member to be used in a structure with no members and it behaves the same as a zero-sized array in a structure with no members: https://godbolt.org/z/Gx7ozxYKz


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114080/new/

https://reviews.llvm.org/D114080



More information about the cfe-commits mailing list