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

    <tr>
        <th>Summary</th>
        <td>
            Clang accepts illegal flexible array member inside struct used in std::vector
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          GINN-Imp
      </td>
    </tr>
</table>

<pre>
    https://godbolt.org/z/brW45GE3h
Clang -std=c++17 -pedantic accepts the following code:
```cpp
#include <vector>

struct Bad {
    struct {} i[];
};

int main() {
 std::vector<Bad> v;
}
```

Expected (GCC):
```
In file included from /opt/compiler-explorer/gcc-trunk-20250409/include/c++/15.0.1/vector:68,
 from <source>:1:
/opt/compiler-explorer/gcc-trunk-20250409/include/c++/15.0.1/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = Bad; _Alloc = std::allocator<Bad>]':
/opt/compiler-explorer/gcc-trunk-20250409/include/c++/15.0.1/bits/stl_vector.h:561:7: required from here
  561 |       vector() = default;
      | ^~~~~~
/opt/compiler-explorer/gcc-trunk-20250409/include/c++/15.0.1/bits/stl_vector.h:376:49: error: arithmetic on pointer to an empty aggregate
  376 | _M_impl._M_end_of_storage - _M_impl._M_start);
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
Compiler returned: 1
```


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VMFu4zYQ_ZrxZWBDIiXLPuggK1aQw-5p0R4FihzLbClRJals0kO-vaAl7yYpeiuWMGB7yOHMe_P4hPe6H4lKyE-QP2zEHK7WlY9PX79un4Zp01n1Wl5DmDzwClgDrOmt6qwJO-t6YM3fwJrO_Z7lj2d-haSqjRh73PqggD9IYCdgp7TA7URKjEFLFFLSFDyGK-HFGmO_67FHaRXFCkkF-2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