<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/120898>120898</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `{Small,}BitVector.reset(unsigned I, unsigned E)` has off-by-one error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          natanelh-mobileye
      </td>
    </tr>
</table>

<pre>
    consider the following crashing code:
```c++
SmallBitVector BV(31, true);
BV.reset(30, 32);
```
expected behavior: bits 30, 31 are reset
actual behavior: assertion crash:
```sh
 at llvm-project/llvm/include/llvm/ADT/SmallBitVector.h:420
420      assert(E <= size() && "Attempted to reset out-of-bounds range!");
```
it should check `E <= size() + 1` since the end is not included in the range (at least according to the docs).
I am not good enough with bits and bytes to solve the algorithm however and a dumb change of adding one in that check may or may not cause UB later without special handling.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsU8GO4ygQ_ZrypZQIl53EOfjgdCbSnHe37xgqNrsYIsDpzX79CpLp1oxGQrZxFfXqUe_JGM3kmHvYnWB3ruSaZh96J5N0bOfN4kdj-cHV6PWjV95Fozlgmhmv3lr_YdyEKsg4lw-vGZoBxAB78VwK6JSXGP5YpLUnk95ZJR_w9A7UNTXQG6awMtARmpx2et8GjpxyVORoQ5-xz6ogBv73xiqxxpFneTc-QDPgaFLE17EaZWB81hKDVGmV9qdkGSOHZLx7Evil8TiDGFAmtPa-bG7B_80qAV3yFuhinLKr5q8fw_lPoMvPJLe5aEu53fI8vjCBum8IzRs0Z4zmPwbqgI4ItAfaIxANKfFyy-ySf1JAv6aNv25GvzodMUg3MVAN9PvbMQnj7FerUc2s_kHYi98jnrCGvcBonOIyVnYaTUTnE744ajSuhAooAnX5VljGhFIpH3QeffIlRXsVgY5bEMN3lEspM3mvkZ1fpxk_TJqfU5JO4_hIHPPR6O39CS_t5INJ84Kz_-A7h5IoUa_LiGouHfgrSl1QveNnczK9iC7ygT6UV8ZWco2Mf53QysShwPs1YbyxMtLiLJ22xk3bSveNPjZHWXFfH5q2Oxx21FZzPx5UI8eGxXEv62Zs2uZad-21u9aiI9FyZXoS1NZEVLe0o3YrRqn1cXcQ-jp2o2yhFbxIY7dZKFsfpsrEuHJfk-iOXWXlyDYW_xE5_sASzXPdnavQF_WN6xShFdbEFL_KJJMs93neh1PRHdAbHM5f6vvho9UVk2v8no3xufuWlbMXOMuI_nrdjI9Nvk8OwYdqDbafU7rFbAu6AF0mk-Z13Cq_fIn-F2-U1iPQ5cXt3tP_AQAA__9TEWLA">