public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "Keith.S.Thompson at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108986] New: Incorrect warning for [static] array parameter Date: Wed, 01 Mar 2023 18:35:33 +0000 [thread overview] Message-ID: <bug-108986-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108986 Bug ID: 108986 Summary: Incorrect warning for [static] array parameter Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: Keith.S.Thompson at gmail dot com Target Milestone: --- When a parameter is declared with the (new in C99) [static] syntax, and the argument is a null pointer, the warning incorrectly refers to the expected size in bytes of the parameter rather than to its length. That by itself might be annoying but not incorrect, but the warning includes C syntax that is inconsistent with the actual declaration. (When the argument is an array object that's too short, the warning is different. It also refers to a size in bytes, and IMHO referring to the length would be clearer. Details to follow in a comment.) $ cat c.c #include <stddef.h> void f(int a[static 7]) { } int main(void) { f(NULL); } $ gcc --version | head -n 1 gcc (GCC) 12.2.0 $ gcc -Wall -c c.c c.c: In function ‘main’: c.c:6:5: warning: argument 1 to ‘int[static 28]’ is null where non-null expected [-Wnonnull] 6 | f(NULL); | ^~~~~~~ c.c:3:6: note: in a call to function ‘f’ 3 | void f(int a[static 7]) { } | ^ c.c:6:5: warning: argument 1 to ‘int[static 28]’ is null where non-null expected [-Wnonnull] 6 | f(NULL); | ^~~~~~~ c.c:3:6: note: in a call to function ‘f’ 3 | void f(int a[static 7]) { } | ^ $
next reply other threads:[~2023-03-01 18:35 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-01 18:35 Keith.S.Thompson at gmail dot com [this message] 2023-03-01 18:41 ` [Bug c/108986] " Keith.S.Thompson at gmail dot com 2023-03-02 10:11 ` rguenth at gcc dot gnu.org 2023-03-02 15:42 ` [Bug c/108986] [11/12/13 Regression] " jakub at gcc dot gnu.org 2023-03-02 18:09 ` jakub at gcc dot gnu.org 2023-03-03 15:12 ` cvs-commit at gcc dot gnu.org 2023-03-03 15:19 ` [Bug c/108986] [11/12 " jakub at gcc dot gnu.org 2023-03-19 5:30 ` cvs-commit at gcc dot gnu.org 2023-03-20 10:28 ` [Bug c/108986] [11 " jakub at gcc dot gnu.org 2023-05-08 12:26 ` rguenth at gcc dot gnu.org 2023-08-04 14:06 ` muecker at gwdg dot de
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-108986-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).