public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "avarab at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/105285] New: False positive with -Wanalyzer-null-dereference in git.git's reftable/reader.c Date: Fri, 15 Apr 2022 09:39:35 +0000 [thread overview] Message-ID: <bug-105285-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105285 Bug ID: 105285 Summary: False positive with -Wanalyzer-null-dereference in git.git's reftable/reader.c Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: avarab at gmail dot com Target Milestone: --- Created attachment 52813 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52813&action=edit gcc -E of reftable/reader.c I didn't have time to come up with a nice isolated test case this time for $subject, sorry, but (maybe this is easier): git clone https://github.com/git/git/ cd git make CC=gcc CFLAGS=-fanalyzer reftable/reader.o Or alternatively the gcc -E output that's attached, but most informative is the patch I'll attach to git.git to work around this (as the code was pretty nonsensical anyway). Why do I think it's a false positive? It's code that's basically doing: struct x = { 0 }; /* "foo" member is NULL */ if (x >= 0) return 0; /* early abort */ [...] if (x >= 0) return 1; /* we don't init "x.foo" */ x.foo I.e. the analyzer thinks you can go through these two and for "x >= 0" to be true the first time, and false the next, or the other way around. In this case the types didn't have "const" on them, but to make sure these *really* weren't being changed I added that in all the relevant places, but it still complained. The warning was: reftable/reader.c: In function ‘extract_block_size’: reftable/reader.c:274:20: warning: dereference of NULL ‘data’ [CWE-476] [-Wanalyzer-null-dereference] 274 | *typ = data[0]; | ~~~~^~~ Also, for the GCC 11.2 I have locally (I tested the warning on near-trunk GCC 12.0) I got two different warnings from -fanalyzer, so this seems to be an area that's seen active changes recently...
next reply other threads:[~2022-04-15 9:39 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-15 9:39 avarab at gmail dot com [this message] 2022-04-15 9:49 ` [Bug analyzer/105285] " avarab at gmail dot com 2022-04-15 9:54 ` avarab at gmail dot com 2022-04-15 15:11 ` dmalcolm at gcc dot gnu.org 2022-04-27 17:56 ` dmalcolm at gcc dot gnu.org 2022-04-27 18:07 ` dmalcolm at gcc dot gnu.org 2022-04-27 18:08 ` dmalcolm at gcc dot gnu.org 2022-04-27 18:08 ` dmalcolm at gcc dot gnu.org 2022-04-27 19:24 ` dmalcolm at gcc dot gnu.org 2022-04-28 17:48 ` cvs-commit at gcc dot gnu.org 2022-04-28 17:51 ` cvs-commit at gcc dot gnu.org 2022-04-28 17:57 ` dmalcolm at gcc dot gnu.org 2022-07-27 21:55 ` cvs-commit at gcc dot gnu.org 2022-07-27 21:55 ` cvs-commit at gcc dot gnu.org 2022-07-27 22:09 ` 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-105285-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).