public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/56574] False "may be uninitialized variable" warning (&& converted to &)
Date: Fri, 26 Mar 2021 15:36:45 +0000	[thread overview]
Message-ID: <bug-56574-4-TEg4Xk2nLB@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56574-4@http.gcc.gnu.org/bugzilla/>

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
      Known to fail|                            |10.2.0, 11.0, 4.7.4, 4.8.4,
                   |                            |4.9.4, 5.5.0, 6.4.0, 7.2.0,
                   |                            |8.3.0, 9.1.0
                 CC|                            |msebor at gcc dot gnu.org
   Last reconfirmed|2013-03-11 00:00:00         |2021-3-26

--- Comment #12 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirming for GCC 11.

With a slightly tweaked test case and a patched GCC to print the conditions
under which it determines the variable is uninitialized the note after the
warning makes it clear even without looking at the dump that the warning is a
false positive.

$ cat pr56574.c && gcc -O2 -S -Wuninitialized -Wmaybe-uninitialized
-fdump-tree-uninit=/dev/stdout pr56574.c
int f (void);

void g (int i)
{
  int x;

  if (i == 0)
    x = f ();

  for (;;)
    {
    if (i == 0 && x)
      continue;

    if (i == 0)
      break;
  }
}

;; Function g (g, funcdef_no=0, decl_uid=1945, cgraph_uid=1, symbol_order=0)

0 dep_chains for phi_bb 4, use_bb 4:
        tmp chain = i_6(D) == 0
one_pred = i_6(D) == 0
pr56574.c: In function ‘g’:
pr56574.c:12:16: warning: ‘x’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   12 |     if (i == 0 && x)
      |                ^~
pr56574.c:5:7: note: when ‘i != 0’
    5 |   int x;
      |       ^
pr56574.c:5:7: note: ‘x’ was declared here
void g (int i)
{
  int x;
  _Bool _14;
  _Bool _15;
  _Bool _16;

  <bb 2> [local count: 79134772]:
  if (i_6(D) == 0)
    goto <bb 3>; [33.00%]
  else
    goto <bb 11>; [67.00%]

  <bb 11> [local count: 53020297]:
  goto <bb 4>; [100.00%]

  <bb 3> [local count: 26114475]:
  x_10 = f ();

  <bb 4> [local count: 79134772]:
  # x_11 = PHI <x_7(D)(11), x_10(3)>
  _14 = i_6(D) == 0;
  _15 = x_11 != 0;
  _16 = _14 & _15;

  <bb 5> [local count: 719407024]:

  <bb 6> [local count: 1073741824]:
  if (_16 != 0)
    goto <bb 10>; [33.00%]
  else
    goto <bb 7>; [67.00%]

  <bb 10> [local count: 354334800]:
  goto <bb 6>; [100.00%]

  <bb 7> [local count: 719407024]:
  if (i_6(D) == 0)
    goto <bb 8>; [11.00%]
  else
    goto <bb 9>; [89.00%]

  <bb 9> [local count: 640272252]:
  goto <bb 5>; [100.00%]

  <bb 8> [local count: 79134772]:
  return;

}

  parent reply	other threads:[~2021-03-26 15:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08 19:10 [Bug c/56574] New: False possibly uninitialized variable warning mark.d.rustad at intel dot com
2013-03-08 19:25 ` [Bug c/56574] " mark.d.rustad at intel dot com
2013-03-08 19:51 ` [Bug middle-end/56574] " pinskia at gcc dot gnu.org
2013-03-08 21:11 ` thiago at kde dot org
2013-03-08 21:26 ` pinskia at gcc dot gnu.org
2013-03-11 10:44 ` rguenth at gcc dot gnu.org
2013-03-11 10:45 ` rguenth at gcc dot gnu.org
2014-06-06  1:06 ` luto at mit dot edu
2014-06-06  7:55 ` ebotcazou at gcc dot gnu.org
2014-06-06 12:27 ` manu at gcc dot gnu.org
2021-03-26 15:36 ` msebor at gcc dot gnu.org [this message]
2021-05-04 12:32 ` [Bug middle-end/56574] False "may be uninitialized variable" warning (&& converted to &) rguenth at gcc dot gnu.org
2022-03-16  8:36 ` [Bug tree-optimization/56574] " coenraad at wish dot org.za
2022-03-16  8:39 ` pinskia 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-56574-4-TEg4Xk2nLB@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).