[Bug tree-optimization/101912] -Wmaybe-uninitialized false alarm in tzdb localtime.c

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 16 17:07:17 GMT 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
      Known to fail|                            |10.3.0, 11.2.0, 12.0,
                   |                            |6.5.0, 7.5.0, 8.5.0, 9.3.0
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
                 CC|                            |msebor at gcc dot gnu.org
   Last reconfirmed|                            |2021-08-16

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed, not a regression.  The warning pass considers only one condition: n
> 0.  It doesn't consider the conjunction of that condition with those implied
by not using the other unintialized PHI operand and that the use is unreachable
otherwise (i.e., that !(corr == 1 && leapcnt != 0 && prevcorr - 1 > 1 && n !=
leapcnt) cannot be true at the point of the use).  The logic seem too
complicated to me to figure it out but I could be missing something.

int tzloadbody ()
{
  int corr;
  int leapcnt;
  int prevcorr;
  int n;
  _Bool _1;
  _Bool _2;
  _Bool _5;
  unsigned int _6;
  int _8;
  unsigned int _9;
  _Bool _21;
  _Bool _27;

  <bb 2> [local count: 95397018]:
  # .MEM_12 = VDEF <.MEM_11(D)>
  n_13 = getint ();
  if (n_13 > 0)
    goto <bb 7>; [96.34%]                               >>> if n > 0...
  else
    goto <bb 9>; [3.66%]

  <bb 7> [local count: 91905487]:                       <<<
...prevcorr_14(D)(7) uninitialized here

  <bb 3> [local count: 1034442874]:                     <<< if n > 0 && !(corr
== 1 && leapcnt != 0 && prevcorr - 1 > 1 && n != leapcnt)
  # prevcorr_18 = PHI <corr_16(8), prevcorr_14(D)(7)>   <<< 
  # leapcnt_23 = PHI <leapcnt_17(8), 0(7)>
  # .MEM_20 = PHI <.MEM_15(8), .MEM_12(7)>
  # .MEM_15 = VDEF <.MEM_20>
  corr_16 = getint ();
  if (corr_16 <= 0)
    goto <bb 10>; [3.66%]
  else
    goto <bb 4>; [96.34%]

  <bb 4> [local count: 996582264]:
  _1 = corr_16 == 1;
  _2 = leapcnt_23 != 0;
  _9 = (unsigned int) prevcorr_18;                       <<<
-Wmaybe-uninitialized
  _6 = _9 + 4294967295;
  _5 = _6 > 1;
  _21 = _1 & _2;
  _27 = _5 & _21;
  if (_27 != 0)
    goto <bb 11>; [21.78%]
  else
    goto <bb 5>; [78.22%]                               >>> corr == 1 &&
leapcnt != 0 && prevcorr - 1 > 1

  <bb 11> [local count: 217055616]:
  goto <bb 6>; [100.00%]

  <bb 5> [local count: 978344809]:
  leapcnt_17 = leapcnt_23 + 1;
  if (n_13 != leapcnt_17)
    goto <bb 8>; [96.34%]                               >>> corr == 1 &&
leapcnt != 0 && prevcorr - 1 > 1 && n != leapcnt
  else
    goto <bb 12>; [3.66%]

  <bb 12> [local count: 35807421]:
  goto <bb 6>; [100.00%]

  <bb 8> [local count: 942537388]:
  goto <bb 3>; [100.00%]                                >>> corr == 1 &&
leapcnt != 0 && prevcorr - 1 > 1 && n != leapcnt

  <bb 9> [local count: 3491531]:

  <bb 6> [local count: 95397019]:
  # _8 = PHI <0(9), n_13(12), -1(11), -1(10)>
  # .MEM_10 = PHI <.MEM_12(9), .MEM_15(12), .MEM_15(11), .MEM_15(10)>
  # VUSE <.MEM_10>
  return _8;

}


More information about the Gcc-bugs mailing list