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;

}

Reply via email to