Hi Eric, >> Would you agree that this "error: flexible array member" >> should also be emitted for a zero-sized array member, >> maybe as "error: zero-sized array member not at end of struct"? > > I would have answered yes when zero-sized arrays where introduced, but it's > far less clear a couple of decades later IMO.
But if zero-sized arrays everywhere in a structure is valid C, then the attached test case is a valid test case. And it will break your patch for PR58570 at -O1 and above, because you can no longer assume that different array members are not an alias. Regards Bernd.
int printf (const char *, ...); struct S { char a[0]; short b[1]; }; int e = 1, i; static struct S d; int main () { if (e) { d.b[i]=!d.b[i]; //0->1 d.a[i]=!d.a[i]; //1->0 d.b[i]=!d.b[i]; //0->1 } printf ("%d\n", d.b[0]); return 0; }