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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-02-15
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |amacleod at redhat dot com,
                   |                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you mean with -O3 on the
#include <vector>

void shrink(std::vector<int>& v, unsigned n) {
    if (v.size() < n)
      __builtin_unreachable();
    v.resize(v.size() - n);
}
testcase (with -O2 _M_default_append isn't nlined), then I think it is
something that ideally ranger's symbolic handling should figure out but
doesn't.
We have:
  long unsigned int _1;
...
  long unsigned int _11;
...
  if (_1 > _11)
    goto <bb 3>; [0.00%]
  else
    goto <bb 4>; [100.00%]

  <bb 3> [count: 0]:
  __builtin_unreachable ();

  <bb 4> [local count: 1073741824]:
  # RANGE ~[2305843009213693952, 16140901060200890368]
  _2 = _11 - _1;
  if (_2 > _11)
and we don't figure out that _2 > _11 is always false, because we earlier
assert that _1 <= _11 and so _11 - _1 will not wrap around and so the result _2
<= _11.

Reply via email to