public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/98541] warning with -Wnonnull for array parameter with bound > 0 Date: Wed, 06 Jan 2021 18:08:19 +0000 [thread overview] Message-ID: <bug-98541-4-iSUc0xwJj6@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-98541-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98541 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC| |msebor at gcc dot gnu.org Last reconfirmed| |2021-01-06 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- Both the warning in the VLA case and its absence in the ordinary case are by design. The VLA case gets a warning because it seems suspicious to specify a nonzero number of elements for an array and then null as the array (the VLA parameter can be null when the bound is zero). But I didn't consider the shared bound use case so I suppose the warning could be relaxed to accommodate it, and either changed to rely on the [static] for the bound as you suggest or on the VLA parameter declared with attribute nonnull. I can't think of a use case where the bound isn't shared and where setting it to nonzero and passing a null pointer would not be a bug. My rationale for not issuing a warning for ordinary arrays with constant bounds is that those are commonly treated as "optional," and so there relying on some additional notation ([static] or nonnull) seems appropriate and necessary to prevent this use case.
next prev parent reply other threads:[~2021-01-06 18:08 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-05 16:12 [Bug c/98541] New: " muecker at gwdg dot de 2021-01-06 18:08 ` msebor at gcc dot gnu.org [this message] 2021-01-06 18:12 ` [Bug c/98541] " msebor at gcc dot gnu.org 2021-01-06 19:06 ` muecker at gwdg dot de 2023-11-03 22:21 ` cvs-commit at gcc dot gnu.org 2023-11-04 10:01 ` uecker at gcc dot gnu.org
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-98541-4-iSUc0xwJj6@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).