(int[]){}; produces no diagnostics with -std=c23 -pedantic. Empty initalizer lists are OK under -std=c23 and -std=gnu so that's not the problem. gcc correctly gives a diagnostic for that in -std=c17 -pedantic mode. Zero-sized arrays should however give a diagnostic in -std=cxx -pedantic mode. Prior to C23 this was not really a problem as we would get a diagnostic for the empty initializer list. But now this non-conforming C compiles cleanly even with -pedantic set. A diagnostic similar to the one given in clang would be good: warning: zero size arrays are an extension [-Wzero-length-array] As I understand it, gcc did have -Wzero-length-array in the past but removed it? See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94428. The options -Wstrict-flex-arrays -fstrict-flex-arrays seem to have no effect (and my example isn't a flexible array member but a compound literal).
Created attachment 57643 [details] Complete example
The relevant constraint here is "An array of unknown size shall not be initialized by an empty initializer.".
(In reply to Joseph S. Myers from comment #2) > The relevant constraint here is "An array of unknown size shall not be > initialized by an empty initializer.". Indeed! I didn't realize it was also a constraint (C23 6.7.10). That probably means that a diagnostic warning should always be given and not just in -pedantic mode.