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

    <tr>
        <th>Summary</th>
        <td>
            UBSan: unsigned-integer-overflow false positive that should be handled better
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          luke-jr
      </td>
    </tr>
</table>

<pre>
    ```c++
std::vector<char> whatever;
for (auto i{whatever.size()}; i--; ) {
    // do something
}
```

This seems to be the most logically optimal way to go over all elements of a vector (or similar). Yet unsigned-integer-overflow has a false positive on it. I would think it'd be pretty simple to detect that the overflow results in `i` going out of scope before any access?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9Uk2TmzAM_TXmoknGmBCWA4fNpjvTc9tDjwYr4F2DGSSSSX99ZbLbzvRQRtiy9fWepTa6e6OO-iGdMqck-qz0M7FTxbPIFTuOiypeusHK9gVug2W8ougfrpe4gDJPduUIXlWnT4c9-V8oBmVqVZ3FHfxulza5APF7RIN8yryKgItAcUQe_NQ_jCnuoXyC_Dhu6_fBExDiSCClWwQeEMZIDCH2vrMh3CHO7Ecb4GbvyamPEAUaiA0w4IgTE8QLWHjwTERkJT_6IHRNvYefyLBO5PsJ3c5PjD0uu5TkEuINBksSfLGBEOZInv0VIU7geQ9f4RbX4CARepcbZSqXYM4LMt9TkTlgQuWQpbr4Wd44_Mm-IK1BEPoJhLuXXxjI60BcOcGmLs4oKaUFCHa6g-06JFLFa4ZNfjwWRZU_6TpzTeHqorYZew7Y_Dh9s5P09j-8_mG0QaNhoyMMBju5gEllxiVbl9AMzDOlkdl62Xse1nbfxVEOIVw_t928xDfhKkdPtCKJUlZVfciGxlwORdnmOm9Lq9GWT87p3HQHV2qL7VFnwbYYqFGljKmZ8AZbCtFVec58Y7Qxus6PpjgU0jhtqq7SRVnlx7o66EodNI7Wh33CsY9Lny3NBqldexJj8MT012hpexrcykl-Ge8hSsT6jru3JdtKNxv03wzFDK4">