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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
This is the simple case of GCC optimizing the access to a constant:

  <bb 2> [50.00%]:
  max.0_11 = max;
  if (max.0_11 > 1)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [25.00%]:
  _13 = right[0];
  left[1] = _13;

  <bb 4> [50.00%]:
  return;

and we warn for the case of max > 1.

Similarly we warn for

int bar () { return left[2]; }

even if we can't prove that bar() is actually executed.

We could change the warning to have a "may be above array bounds" form
for your case but that wouldn't handle the bar() case.

Reply via email to