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/103658] missing -Wanalyzer-use-of-uninitialized-value at -O1 and below for an array access Date: Wed, 09 Feb 2022 20:59:19 +0000 [thread overview] Message-ID: <bug-103658-4-aXihsosubc@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103658-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103658 --- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> --- Note that with -fno-analyzer-state-merge, -fanalyzer warns without optimization and shows the conditionals you hoped to see: ./xgcc -B. -S -fanalyzer /tmp/foo.c -fno-analyzer-state-merge /tmp/foo.c: In function 'f': /tmp/foo.c:9:11: warning: use of uninitialized value 'a[<unknown>]' [CWE-457] [-Wanalyzer-use-of-uninitialized-value] 9 | return a[i + j]; | ~^~~~~~~ 'f': events 1-6 | | 3 | int a[3]; | | ^ | | | | | (1) region created on stack here |...... | 7 | if (i < 1) i = 1; | | ~ ~~~~~ | | | | | | | (3) ...to here | | (2) following 'true' branch (when 'i <= 0')... | 8 | if (j < 1) j = 1; | | ~ ~~~~~ | | | | | | | (5) ...to here | | (4) following 'true' branch (when 'j <= 0')... | 9 | return a[i + j]; | | ~~~~~~~~ | | | | | (6) use of uninitialized value 'a[<unknown>]' here | Not sure why it's printing <unknown> for the index though.
next prev parent reply other threads:[~2022-02-09 20:59 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-10 21:30 [Bug analyzer/103658] New: " msebor at gcc dot gnu.org 2021-12-10 21:46 ` [Bug analyzer/103658] " msebor at gcc dot gnu.org 2022-02-09 20:59 ` dmalcolm at gcc dot gnu.org [this message] 2022-02-09 21:12 ` 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-103658-4-aXihsosubc@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).