https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102805
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm:
  <bb 3> [local count: 751619281]:
  if (end_8(D) > start_9(D))
    goto <bb 4>; [33.00%]
  else
    goto <bb 15>; [67.00%]

  <bb 4> [local count: 248034361]:
  _2 = end_8(D) - start_9(D);
  _3 = _2 + 1;
  data ={v} {CLOBBER};
  _23 = (signed long) _3;
  if (_23 < 0)
    goto <bb 5>; [0.04%]
  else
    goto <bb 6>; [99.96%]

  <bb 5> [local count: 99214]:
  std::__throw_length_error ("cannot create std::vector larger than
max_size()");

  <bb 6> [local count: 247935148]:
  MEM[(struct _Vector_impl_data *)&data] ={v} {CLOBBER};
  MEM[(struct _Vector_impl_data *)&data]._M_start = 0B;
  MEM[(struct _Vector_impl_data *)&data]._M_finish = 0B;
  MEM[(struct _Vector_impl_data *)&data]._M_end_of_storage = 0B;
  if (_3 != 0)
    goto <bb 8>; [71.00%]
  else
    goto <bb 7>; [29.00%]

  <bb 7> [local count: 71901193]:
  MEM[(struct _Vector_base *)&data]._M_impl.D.49479._M_start = 0B;
  MEM[(struct _Vector_base *)&data]._M_impl.D.49479._M_finish = 0B;
  MEM[(struct _Vector_base *)&data]._M_impl.D.49479._M_end_of_storage = 0B;
  goto <bb 9>; [100.00%]

  <bb 8> [local count: 158430559]:
  _33 = operator new (_3);
  MEM[(struct _Vector_base *)&data]._M_impl.D.49479._M_start = _33;
  MEM[(struct _Vector_base *)&data]._M_impl.D.49479._M_finish = _33;
  _28 = _33 + _3;
  MEM[(struct _Vector_base *)&data]._M_impl.D.49479._M_end_of_storage = _28;
  *_33 = 0;
  __first_35 = _33 + 1;
  _41 = (long int) _2;
  __builtin_memset (__first_35, 0, _2);


if end is UINT64_MAX and start is 0, then _2 would be UINT64_MAX and _3 would
be 0. And _23 < 0 would be false and then _3!=0 would be false..

So I think the warning is correct, just you don't have an wrapping check
defined in the code for (end - start + 1) .......

Reply via email to