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/106204] New: False positive from -Wanalyzer-use-of-uninitialized-value with -ftrivial-auto-var-init=zero
Date: Tue, 05 Jul 2022 18:04:08 +0000	[thread overview]
Message-ID: <bug-106204-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106204
           Summary: False positive from
                    -Wanalyzer-use-of-uninitialized-value with
                    -ftrivial-auto-var-init=zero
           Product: gcc
           Version: 12.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: ---

I'm seeing a lot of false positives from -Wanalyzer-use-of-uninitialized-value
when building the upstream Linux kernel.

Seems to be a bad interaction with -ftrivial-auto-var-init=zero; minimal
reproducer:

$ cat ../../src/hooks.c
int foo(unsigned *len);
int test()
{
 unsigned len;
 int rc;

 rc = foo(&len);
 if (!rc)
  rc = len;
 return rc;
}

$ ./xgcc -B. ../../src/hooks.c -ftrivial-auto-var-init=zero -fanalyzer -S 
../../src/hooks.c: In function ‘test’:
../../src/hooks.c:4:11: warning: use of uninitialized value ‘<unknown>’
[CWE-457] [-Wanalyzer-use-of-uninitialized-value]
    4 |  unsigned len;
      |           ^~~
  ‘test’: event 1
    |
    |    4 |  unsigned len;
    |      |           ^~~
    |      |           |
    |      |           (1) use of uninitialized value ‘<unknown>’ here
    |

where the uninit is being reported on the assignment to "len = _1;" here:

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

             reply	other threads:[~2022-07-05 18:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 18:04 dmalcolm at gcc dot gnu.org [this message]
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
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@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).