<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/84565>84565</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Allow C99 flexible array members in unions and alone in structs like 0-length arrays
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kees
</td>
</tr>
</table>
<pre>
GNU and MSVC have extensions where flexible array members (or their equivalent) can be in unions or alone in structs. This is already fully supported in Clang through the 0-sized array ("fake flexible array") extension or when C99 flexible array members have been syntactically obfuscated.
Please explicitly allow these extensions directly for C99 flexible arrays, since they are common code patterns in active use by the Linux kernel (and other projects). Such projects have been using either 0-sized arrays (which is considered deprecated in favor of C99 flexible array members) or via obfuscated syntax, both of which complicate their code bases.
For example, these do not error by default:
```
union one {
int a;
int b[0];
};
union two {
int a;
struct {
struct { } __empty;
int b[];
};
};
```
But this does:
```
union three {
int a;
int b[];
};
```
Matching request has been made to GCC as well: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53548
@nickdesaulniers
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlE1v4zYTxz8NdRnEUCgptg46JDa8l2cfFNi212BEjkQ2FOnli1_20xeU3Y0VdIMCgSKPOMP__Dj8Ywh6tEQda15YsyswReV890YUit7JS_fl_38AWglfv_25BYVHAjpHskE7G-CkyBMMhs66NwToPV5goqknH4DxjfMQFWkP9D3pIxqykfEWBFroCbSFZOc6zgMaZ-dQiD6JGFbwu9IBdAA0nlBeYEjGXCCkw8H5SDKv3Rq0I0TlXRpV3grKh6B_kLxJYXzDOB_w7aNIxnkW8rOVrOCkyMK2bX_Vz9x8T2QhXGxEEbXArMj1QwoCI8kVK3esfL4-fzOEIdM6GC10NBdAY9wpqwwLiFJ7Evn74Py_7B8Y30LQVlBOvQB6AuGmyVkQThIcMEbyNmQeWdSRIAWC_jLz-J-26Qxv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