public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "alx at kernel dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/108036] [11/12/13/14 Regression] Spurious warning for zero-sized array parameters to a function Date: Thu, 07 Mar 2024 10:53:46 +0000 [thread overview] Message-ID: <bug-108036-4-vu1kllenLH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108036-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108036 --- Comment #9 from Alejandro Colomar <alx at kernel dot org> --- Hi Lundin! On Thu, Mar 07, 2024 at 10:18:12AM +0000, daniel.lundin.mail at gmail dot com wrote: > --- Comment #8 from Daniel Lundin <daniel.lundin.mail at gmail dot com> --- > I don't believe char past_end[0] is valid C, because it is an invalid array > declaration. Unlike [] or [*] that declares an array of incomplete type. > > Since it is a function parameter, it will of course later get adjusted to a > pointer to the first element. But it still has to be a valid declaration to > begin with. Similarly, char arr[][] is invalid because it remains an incomplete > type after adjustment (see C17 6.7.6.4 §4). Agree; ISO C seems to not allow this with their wording. (I wish it did, because it's just a matter of wording, not that they don't allow passing a pointer to past the end). But maybe the wording needed for allowing this would have other undersirable consequences, so I'm happy as long as GNU C would support this. > gcc does allow [0] as an extension since that was commonly used for purposes of > implementing the "struct hack" back in the days before flexible array members > were standardized. > > The conclusion ought to be that gcc should let [0] through if compiled in > -std=gnu23 mode but not in -std=c23 and/or -pedantic. And agree; if support for this is added, pedantic or ISO C modes should complain about it. Have a lovely day! Alex
prev parent reply other threads:[~2024-03-07 10:53 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-09 17:24 [Bug c/108036] New: " colomar.6.4.3 at gmail dot com 2022-12-09 19:09 ` [Bug c/108036] " pinskia at gcc dot gnu.org 2022-12-09 19:13 ` [Bug middle-end/108036] [11/12/13 Regression] " pinskia at gcc dot gnu.org 2022-12-09 19:13 ` pinskia at gcc dot gnu.org 2022-12-09 19:18 ` colomar.6.4.3 at gmail dot com 2022-12-09 19:22 ` pinskia at gcc dot gnu.org 2022-12-09 19:23 ` colomar.6.4.3 at gmail dot com 2022-12-21 11:45 ` rguenth at gcc dot gnu.org 2023-05-29 10:07 ` [Bug middle-end/108036] [11/12/13/14 " jakub at gcc dot gnu.org 2024-03-07 10:18 ` daniel.lundin.mail at gmail dot com 2024-03-07 10:53 ` alx at kernel dot org [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108036-4-vu1kllenLH@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).