Undefined behavior, and the sledgehammer principle
C&#x2F;C++ has a historic preference for using signed &quot;int&quot; in places where it&#x27;s not appropriate. Unsigned arithmetic is better defined - it wraps. So you don&#x27;t have undefined behavior around arithmetic.<p>Use size_t for indices. That&#x27;s defined as an unsigned value big enough to index the largest possible array. Rust uses &quot;usize&quot; for the same purpose. Only use signed integers where negative values are meaningful.