https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128603

            Bug ID: 128603
           Summary: __is_array is inconsistent with overload resolution on
                    zero size arrays
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nikolasklauser at berlin dot de
  Target Milestone: ---

Consider this beautiful piece of code:
```
struct S {
  int a[0];
};

static_assert(__is_array(S[]));
static_assert(__is_array(S[10]));

template <class T, int N>
constexpr int func(T(&)[N]) {
  return N;
}

void test() {
  S arr[10];
  static_assert(func(arr) == 10);
}
```
The first `static_assert` passes, while the second fails. The third passes
again. I don't know why GCC behaves this way, but it seems inconsistent. Clang
accepts this.

P.S. I'd be perfectly happy if the conclusion here is that arrays of zero size
types should be rejected. I don't see a scenario where this is useful other
than to file bugs against compilers (I've found this through a libc++ test
case).

Reply via email to