https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94428
Bug ID: 94428 Summary: Reintroduce -Wzero-length-array Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: kees at outflux dot net Target Milestone: --- It would be nice to gain "-Wzero-length-array" so we can enforce this standard in the Linux kernel once all conversions have moved struct to flexible array members. Clang supports this as a distinct warning, but gcc currently only warns about this under "-pedantic -std=c99", which is not a workable combination for Linux. ;) $ clang -Wzero-length-array -o bounds-clang bounds.c bounds.c:20:15: warning: zero size arrays are an extension [-Wzero-length-array] char data[0]; ^ $ gcc -Wzero-length-array -o bounds-gcc bounds.c gcc: error: unrecognized command line option ‘-Wzero-length-array’ $ gcc -pedantic -std=c99 -o bounds-gcc bounds.c bounds.c:20:10: warning: ISO C forbids zero-size array ‘data’ [-Wpedantic] 20 | char data[0]; | ^~~~