public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "muecker at gwdg dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/98541] New: warning with -Wnonnull for array parameter with bound > 0 Date: Tue, 05 Jan 2021 16:12:12 +0000 [thread overview] Message-ID: <bug-98541-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98541 Bug ID: 98541 Summary: warning with -Wnonnull for array parameter with bound > 0 Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: muecker at gwdg dot de Target Milestone: --- In the example void foo(int n, double x[n]); void f(void) { foo(1, 0); } there is a warning x.c: In function ‘f’: x.c:7:9: warning: argument 1 of variable length array ‘double[n]’ is null but the corresponding bound argument 2 value is 1 [-Wnonnull] 7 | foo(1, 0); | ^~~~~~~~~ x.c:3:6: note: in a call to function ‘foo’ 3 | void foo(int n, double x[n]); | ^~~ But the bound > 0 does not imply that 'x' is not NULL. (static would imply this). There is also no warning with a constant bound > 0. Passing NULL is useful for optional arguments and when the bound is shared between different parameters, it can not be passed as zero.
next reply other threads:[~2021-01-05 16:12 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-05 16:12 muecker at gwdg dot de [this message] 2021-01-06 18:08 ` [Bug c/98541] " msebor at gcc dot gnu.org 2021-01-06 18:12 ` 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@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).