public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/96894] New: Analyzer assumes pointer is NULL, even if pointer was tested to be non-null before Date: Wed, 02 Sep 2020 07:44:37 +0000 [thread overview] Message-ID: <bug-96894-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96894 Bug ID: 96894 Summary: Analyzer assumes pointer is NULL, even if pointer was tested to be non-null before Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- Created attachment 49174 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49174&action=edit fibheap.c, preprocessed version from gdb/binutils master Using gcc-11 (SUSE Linux) 11.0.0 20200901 (experimental) [revision b1850c617b14eedaf60b358f3b7d4707cff73b8a]. Invoked like this: ... $ gcc-11 fibheap.c -fanalyzer -S ... We have: ... fibheap.c: In function ‘fibnode_remove’: fibheap.c:3122:42: warning: dereference of NULL ‘*(node).parent’ [CWE-690] [-Wanalyzer-null-dereference] 3122 | && node->parent->child == node) | ~~~~~~~~~~~~^~~~~~~ ... Looking at the source code, we have: ... 3118 if (node->parent != 3119 3120 ((void *)0) 3121 3122 && node->parent->child == node) 3123 node->parent->child = ret; ... So, just before dereferencing node->parent, we check that it's non-null, so the warning that node->parent is dereferenced while it's null makes no sense.
next reply other threads:[~2020-09-02 7:44 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-02 7:44 vries at gcc dot gnu.org [this message] 2020-09-02 19:14 ` [Bug analyzer/96894] " dmalcolm at gcc dot gnu.org 2021-02-14 17:25 ` dimhen at gmail dot com 2021-03-03 18:37 ` [Bug analyzer/96894] State explosion on gdb's fibheap.c dmalcolm at gcc dot gnu.org 2021-03-12 21:52 ` dmalcolm 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-96894-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).