public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/99771] Analyzer diagnostics should not say "<unknown>" Date: Mon, 07 Mar 2022 19:21:29 +0000 [thread overview] Message-ID: <bug-99771-4-xSnDouYkru@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99771-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99771 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>: https://gcc.gnu.org/g:0af37ad4422052be4b7f779737e14c80e57d0ad9 commit r12-7525-g0af37ad4422052be4b7f779737e14c80e57d0ad9 Author: David Malcolm <dmalcolm@redhat.com> Date: Mon Mar 7 14:19:30 2022 -0500 analyzer: fix leak suppression at end of 'main' [PR101983] PR analyzer/101983 reports what I thought were false positives from -Wanalyzer-malloc-leak, but on closer inspection, the analyzer is correctly reporting heap-allocated buffers that are no longer reachable. However, these "leaks" occur at the end of "main". The analyzer already has some logic to avoid reporting leaks at the end of main, where the leak is detected at the end of the EXIT basic block. However, in this case, the leak is detected at the clobber in BB 2 here: <bb 2> : func (&res); res ={v} {CLOBBER(eol)}; _4 = 0; <bb 3> : <L0>: return _4; where we have a chain BB 2 -> BB 3 -> EXIT BB. This patch generalizes the "are we at the end of 'main'" detection to handle such cases, silencing -Wanalyzer-malloc-leak on them. There's a remaining issue where the analyzer unhelpfully describes one of the leaking values as '<unknown>', rather than 'res.a', but I'm leaving that for a followup (covered by PR analyzer/99771). gcc/analyzer/ChangeLog: PR analyzer/101983 * engine.cc (returning_from_function_p): New. (impl_region_model_context::on_state_leak): Use it when rejecting leaks at the return from "main". gcc/testsuite/ChangeLog: PR analyzer/101983 * gcc.dg/analyzer/pr101983-main.c: New test. * gcc.dg/analyzer/pr101983-not-main.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
next prev parent reply other threads:[~2022-03-07 19:21 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-25 15:26 [Bug analyzer/99771] New: " dmalcolm at gcc dot gnu.org 2021-03-25 15:26 ` [Bug analyzer/99771] " dmalcolm at gcc dot gnu.org 2021-03-30 21:52 ` cvs-commit at gcc dot gnu.org 2021-03-31 23:18 ` cvs-commit at gcc dot gnu.org 2021-03-31 23:21 ` dmalcolm at gcc dot gnu.org 2022-03-07 19:21 ` cvs-commit at gcc dot gnu.org [this message] 2022-03-08 19:17 ` cvs-commit 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-99771-4-xSnDouYkru@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).