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

Kees Cook via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 19:47:34 PDT 2024


kees wrote:

I guess I don't have a strong opinion here, since these helpers are specific to C++, and I've been generally trying to remove fixed-size 0-sized arrays in C projects (i.e. the Linux kernel). I do care about C flexible arrays (and their associated extensions), though. I suspect there is some existing weirdness for C++ when using static initializers, though. See https://godbolt.org/z/PnYMcxhfM

```
struct S { int a; int b[]; };
static struct S s = { .a = 42, .b = { 10, 20, 30, 40 }, };
static struct S z = { .a = 13, };
```

Specifically `z.b` is a 0-sized flexible array, but `s.b` isn't. Should they have different results?

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


More information about the cfe-commits mailing list