public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mengli.ming at outlook dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/108403] New: -Wanalyzer-null-dereference false negative with *q == 0 Date: Sat, 14 Jan 2023 07:30:40 +0000 [thread overview] Message-ID: <bug-108403-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108403 Bug ID: 108403 Summary: -Wanalyzer-null-dereference false negative with *q == 0 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: mengli.ming at outlook dot com Target Milestone: --- I got a false negative error when compiling the following program with gcc(trunk) `-O0 -fanalyzer` in https://godbolt.org/z/4f7e3z8dE. In this case, after entering the first if branch, the result of eval on line 10 is TRUE. At this time, the fact known to the analyzer is that the pointer `q` is NULL, and then, for `*q == 0` on line 11, analyzer does not generate an NPD warning, which is a little odd. Here is the analysis results of the case. Thank you for taking the time to review this case. Input: ```c #include "stdio.h" void __analyzer_eval(int); int *f(int *); int *f(int *q) { __analyzer_eval(q == 0); if (q == 0) { __analyzer_eval(q == 0); if (*q == 0) { printf("Hello World!"); } } } ``` Output: ```bash <source>: In function 'f': <source>:7:5: warning: UNKNOWN 7 | __analyzer_eval(q == 0); | ^~~~~~~~~~~~~~~~~~~~~~~ <source>:10:9: warning: TRUE 10 | __analyzer_eval(q == 0); | ^~~~~~~~~~~~~~~~~~~~~~~ ```
next reply other threads:[~2023-01-14 7:30 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-14 7:30 mengli.ming at outlook dot com [this message] 2023-02-13 8:20 ` [Bug analyzer/108403] " geoffreydgr at icloud dot com
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-108403-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).