<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121398>121398</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang++] Does not error with a zero length array declaration (definition)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          safocl
      </td>
    </tr>
</table>

<pre>
    Clang++ allows declaration (definition) of arrays of zero size (`TYPE NAME[0]`). However, this is prohibited by the c++ standard:
[c++23] ([here](https://timsong-cpp.github.io/cppwp/n4950/dcl.array#1.sentence-3))
```
In a declaration T D where D has the form
D1 [ constant-expression opt ] attribute-specifier-seq opt
[...]
The constant-expression shall be a converted constant expression of type std​::​size_t ([expr.const]).
Its value N specifies the array bound, i.e., the number of elements in the array; N shall be greater than zero.
```


[c++11] ([here](https://timsong-cpp.github.io/cppwp/n3337/dcl.array#1))

[c++17] ([here](https://timsong-cpp.github.io/cppwp/n4659/dcl.array#1))

[Example](https://godbolt.org/z/xT6farz85) :
```
#include <iostream>

struct Data {
   int lhs[0];
   explicit Data(const int rhs) {
    lhs[rhs];
    lhs[0]=rhs;
   }

   void print() {
      std::cout << lhs[0] << "\n";
   }
};


int main() {
   int aaa[0];
   int bbb[0]{};
   Data t(42);
   t.print();
   return sizeof(aaa) + sizeof(bbb);
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVUuP6zYP_TXMhohhS3FiL7JIJhN836IXXcymq0KWmViFIrmSPK9fX9CPeQQX7eYCAhJTInnOISWqGM3VEe2hPEJ5WqkhdT7so7p4bVeNb9_2D1a5K4gjiCMqa_1LxJa0VUEl4x2CqFq6GGf4C0SN_oIqBPUW-d87BY_RvBOfg23-9Mfvj_jj8NsjlMccyhNscxB1hv_zL_RMAcQDps5ENBH74DvTmEQtNm-YOkI9o4hJuVaFFuQB8gOU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