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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
At the point of the diagnostic we see

<bb 2> [local count: 1073741824]:
data._M_elems[0] = 3;
data._M_elems[1] = 2;
data._M_elems[2] = 1;
_8 = getCount ();
_1 = _8 * 4;
_2 = &data._M_elems + _1;
if (&data._M_elems != _2)
  goto <bb 3>; [53.47%]
else
  goto <bb 12>; [46.53%]

that should possibly be optimized to

if (_1 != 0)

but we cannot statically decide this jump.  There's a later dynamic jump
based on the very same _1, a check whether that's > 16, guarded by that
we diagnose

# .MEM_35 = VDEF <.MEM_34>
std::__insertion_sort.isra (&data._M_elems, &MEM <int[3]> [(void *)&data +
64B]);

where we complain about forming the (void *)&data + 64 address.

I can't see a way to suppress the diagnostic completely but it should
be possible to re-word it.

Note using a global getCount without a conditional that this bound
is inside 'data' bounds is not good programming practice.

Reply via email to