I am not sure if this generalizes to non-64 bit platforms, but in my experience using size_t gives you unsigned integer indexing without requiring overflow checks (as it's normally a 64 bit quantity).
This would make sense, since this type is almost always used for iterations and sizes. Anyways I have played with Compiler Explorer and could not spot the "overflow checks" inside some dumb code: https://godbolt.org/z/4znWG8GoP
Maybe this is because x86_64 instruction set is already wrapping up unsigned integers, and maybe the majority of instruction sets are also.
deaddabe|4 years ago
Maybe this is because x86_64 instruction set is already wrapping up unsigned integers, and maybe the majority of instruction sets are also.