public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/94428] New: Reintroduce -Wzero-length-array
@ 2020-04-01  7:23 kees at outflux dot net
  2020-04-01  8:51 ` [Bug c/94428] " marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: kees at outflux dot net @ 2020-04-01  7:23 UTC (permalink / raw)
  To: gcc-bugs

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];
      |          ^~~~

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-20 18:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01  7:23 [Bug c/94428] New: Reintroduce -Wzero-length-array kees at outflux dot net
2020-04-01  8:51 ` [Bug c/94428] " marxin at gcc dot gnu.org
2020-04-01 16:03 ` msebor at gcc dot gnu.org
2021-09-24 19:28 ` kees at outflux dot net
2021-09-24 21:59 ` segher at gcc dot gnu.org
2022-12-20 18:03 ` qinzhao at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).