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

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Without optimization
  https://godbolt.org/z/15v7zMMo5
the analyzer "sees" this gimple IR:

int main ()
{
  const int n;
  char i;
  int D.3184;
  int _1;
  unsigned char i.0_2;
  unsigned char _3;
  int _4;
  int _10;

  <bb 2> :
  n_7 = 500;
  i_8 = 0;
  goto <bb 4>; [INV]

  <bb 3> :
  _1 = (int) i_5;
  printf ("%d\n", _1);
  i.0_2 = (unsigned char) i_5;
  _3 = i.0_2 + 1;
  i_12 = (char) _3;

  <bb 4> :
  # i_5 = PHI <i_8(2), i_12(3)>
  _4 = (int) i_5;
  if (n_7 > _4)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  _10 = 0;

  <bb 6> :
<L3>:
  return _10;

}

The analyzer could probably figure out from:

  char i;
  [...snip...]
  n_7 = 500;
  [...snip...]
  _4 = (int) i_5;
  if (n_7 > _4)

that the conditional is:

  if (500 > (int)(char)X)

and thus always true.

But maybe this would be better placed elsewhere?

Reply via email to