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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 29 07:27:56 PDT 2024


AaronBallman wrote:

> Another option would be to to not acknowledge zero-sized arrays in the type traits at all, just like vector types: https://godbolt.org/z/aP685vz8q. That may be the most consistent stance on this. Basically "It's non-standard and doesn't fit neatly in any of the standard categories, so it's in no category at all."

That's a possibility, though I wonder if it's actually user-friendly to issue a diagnostic if trying to use a non-standard type that can't fit the C++ type traits model. It's annoying for folks writing generic code, but so long as the diagnostic is SFINAE-able, maybe it's okay? My concern is that either returning `true` or `false` from any of those traits may give really surprising results to users, whereas a diagnostic makes it clear "you've wandered off the beaten path here and you need to think more carefully about what this all means". It's not quite as far as the idea of making them invalid types and perhaps is a bad idea, but I'm also somewhat okay with the idea of making it harder to use these non-standard extensions in highly generic code.

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


More information about the cfe-commits mailing list