public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/109239] New: -Wanalyzer-deref-before-check seen on Linux kernel due to inlining with -fno-delete-null-pointer-checks Date: Tue, 21 Mar 2023 19:14:44 +0000 [thread overview] Message-ID: <bug-109239-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109239 Bug ID: 109239 Summary: -Wanalyzer-deref-before-check seen on Linux kernel due to inlining with -fno-delete-null-pointer-checks Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- Created attachment 54724 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54724&action=edit Reproducer I'm seeing various -Wanalyzer-deref-before-check false positives on the Linux kernel; hopefully the attached is a representative reproducer for all of them. When compiled with: -fanalyzer -fno-delete-null-pointer-checks -O2 trunk falsely complains: In function 'bus_get', inlined from 'bus_remove_file' at <source>:122:7, inlined from 'remove_probe_files' at <source>:139:3, inlined from 'bus_unregister' at <source>:150:3: <source>:105:6: warning: check of 'bus' for NULL after already dereferencing it [-Wanalyzer-deref-before-check] 105 | if (bus) { | ^ 'bus_unregister': events 1-2 | | 147 | if (bus->dev_root) | | ~~~^~~~~~~~~~ | | | | | (1) pointer 'bus' is dereferenced here |...... | 150 | remove_probe_files(bus); | | ~ | | | | | (2) inlined call to 'remove_probe_files' from 'bus_unregister' | +--> 'remove_probe_files': event 3 | | 139 | bus_remove_file(bus, &bus_attr_drivers_autoprobe); | | ^ | | | | | (3) inlined call to 'bus_remove_file' from 'remove_probe_files' | +--> 'bus_remove_file': event 4 | | 122 | if (bus_get(bus)) { | | ^ | | | | | (4) inlined call to 'bus_get' from 'bus_remove_file' | +--> 'bus_get': event 5 | | 105 | if (bus) { | | ^ | | | | | (5) pointer 'bus' is checked for NULL here but it was already dereferenced at (1) | Compiler returned: 0 Trunk: https://godbolt.org/z/ErKf6fz86
next reply other threads:[~2023-03-21 19:14 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-21 19:14 dmalcolm at gcc dot gnu.org [this message] 2023-03-22 12:42 ` [Bug analyzer/109239] " cvs-commit at gcc dot gnu.org 2023-03-22 12:48 ` 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-109239-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).