In C, an array is usually not allowed to be of size 0 (unless I use one or the other extension on the compiler side).
OTOH, there are VLAs whose length may be 0.
Are they allowed?
I am talking about the following code:
void send_stuff() { char data[4 * !!flag1 + 2 * !!flag2]; uint8_t cursor = 0; if (flag1) {
The result is a data array with a length of 0, 2, 4, or 6, depending on the combination of flags.
The question is, is this valid code for the case when the array is 0 in length?
source share