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/106204] False positive from -Wanalyzer-use-of-uninitialized-value with -ftrivial-auto-var-init=zero
Date: Wed, 27 Jul 2022 21:55:55 +0000	[thread overview]
Message-ID: <bug-106204-4-Lh29QqfztA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106204-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106204

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by David Malcolm
<dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:09cb9c88ef8e2c0c89ada9cde2caf1a960db7a77

commit r12-8637-g09cb9c88ef8e2c0c89ada9cde2caf1a960db7a77
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Wed Jul 27 17:38:55 2022 -0400

    analyzer: fix uninit false positive with -ftrivial-auto-var-init=
[PR106204]

    (cherry picked from r13-1517-gb33dd7874523af)

    -fanalyzer handles -ftrivial-auto-var-init= by special-casing
    IFN_DEFERRED_INIT to be a no-op, so that e.g.:

      len_2 = .DEFERRED_INIT (4, 2, &"len"[0]);

    is treated as a no-op, so that len_2 is still uninitialized after the
    stmt.

    PR analyzer/106204 reports that -fanalyzer gives false positives from
    -Wanalyzer-use-of-uninitialized-value on locals that have their address
    taken, due to e.g.:

      _1 = .DEFERRED_INIT (4, 2, &"len"[0]);
      len = _1;

    where -fanalyzer leaves _1 uninitialized, and then complains about
    the assignment to "len".

    Fixed thusly by suppressing the warning when assigning from such SSA
    names.

    gcc/analyzer/ChangeLog:
            PR analyzer/106204
            * region-model.cc (within_short_circuited_stmt_p): Move extraction
            of assign_stmt to caller.
            (due_to_ifn_deferred_init_p): New.
            (region_model::check_for_poison): Move extraction of assign_stmt
            from within_short_circuited_stmt_p to here.  Share logic with
            call to due_to_ifn_deferred_init_p.

    gcc/testsuite/ChangeLog:
            PR analyzer/106204
            * gcc.dg/analyzer/torture/uninit-pr106204.c: New test.
            * gcc.dg/analyzer/uninit-pr106204.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

  parent reply	other threads:[~2022-07-27 21:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 18:04 [Bug analyzer/106204] New: " dmalcolm at gcc dot gnu.org
2022-07-05 18:05 ` [Bug analyzer/106204] " dmalcolm at gcc dot gnu.org
2022-07-05 20:08 ` dmalcolm at gcc dot gnu.org
2022-07-06 11:29 ` cvs-commit at gcc dot gnu.org
2022-07-06 11:37 ` dmalcolm at gcc dot gnu.org
2022-07-27 21:55 ` cvs-commit at gcc dot gnu.org [this message]
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-106204-4-Lh29QqfztA@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: link
Be 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).