3 ms·
Also, why use the signed ptrdiff_t for a loop index that is never negative?
by colomon 11y ago
Also, why use the signed ptrdiff_t for a loop index that is never negative?
- benmmurphy 11y agoI thought using signed indexes in loops allow GCC to perform some optimizations because signed overflow is undefined.
- pmelendez 11y ago"size_t can store a pointer, it is better to use another unsinged integer type uintptr_t for that purpose " So he is actually recommending the unsigned version. Although there are some people (like the Google guidelines for C++) that recommend not using unsigned types because of overflows (which is arguable but it is a point)
- aCthrowa 11y agoptrdiff_t is the wrong type for exactly this reason. OP's article is... not good.