[clang] [Clang] Fix __is_array returning true for zero-sized arrays (PR #86652)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 1 05:47:55 PDT 2024


AaronBallman wrote:

> Last time I checked, neither GCC nor Clang allowed T[0] to match a partial specialization for `is_array<T[N]>` so the extension isn't very well extended :)

Oh, I agree, I am learning to loathe this extension the more I look into this. Did you see this lovely bit:

> Oh wow, and it gets even more surprising... adding a zero-length array to a structure reduces the size of the structure (in C++): https://godbolt.org/z/5E4YsT1Ye

But that's why I'm asking questions about what we *should* be doing with the feature overall. As it currently stands, this extension seems like it is broken in C++ in multiple ways. Fixing a tiny corner of it is fine, but I'd like to know what the overall big picture is so we can know whether the tiny corner changes fit or not. We could fix this by changing partial specializations to care about zero-sized arrays, too. (Personally, I would love to "fix" this by deprecating the extension as the only justification for it I've been able to dig up is as a hack for flexible arrays -- deprecating this extension outside of GNU89 mode has some appeal, barring other information about its value.)

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


More information about the cfe-commits mailing list