public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/43361] missing uninitialized warning without optimization (-O0) (PHI in always_executed basic block)
Date: Tue, 30 Mar 2021 07:10:41 +0000	[thread overview]
Message-ID: <bug-43361-4-AaZYKbuVUm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-43361-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #14)
> Reconfirmed with GCC 11 and the C test case below:
> 
> void f (int);
> 
> int main () {
>         int i;
>         int array[10];
>         for (; i<10; ++i) {             // no warning
>                 f (i);                  // no warning
>                 array [i] = i;          // no warning, really hurts
>         }
> }

So what's going "wrong" here is that we figure the BB with the i<10 check
post-dominates the entry block and thus is always executed.  But when
doing warn_uninit on the SSA var we do not consider the value on the
always-executed path from entry (which is uninitialized i_3(D)).

That's for the early pass, the late pass doesn't run at -O0.

Note since we walk BBs in index order which 'i' we warn for is probably
random, I think we'll only warn once since we set TREE_NO_WARNING on the
underlying decl of the SSA name (that's probably misguided - different
SSA defs can have different uninit state).

It might be possible to populate possibly_undefined_names in the BB walk
by visiting PHIs and considering fallthru entries being taken to have this
work out without major restructuring of the pass (a lattice of "undefinedness"
would probably be more to the point).

  parent reply	other threads:[~2021-03-30  7:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-43361-4@http.gcc.gnu.org/bugzilla/>
2011-09-28 22:54 ` [Bug c++/43361] missing uninitialized warning without optimization (loop representation) paolo.carlini at oracle dot com
2013-10-21 12:08 ` manu at gcc dot gnu.org
2021-03-29 17:19 ` [Bug tree-optimization/43361] missing uninitialized warning without optimization (-O0) (PHI in always_executed basic block) msebor at gcc dot gnu.org
2021-03-30  7:10 ` rguenth at gcc dot gnu.org [this message]
2022-08-29 13:25 ` rguenth 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-43361-4-AaZYKbuVUm@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).