I'm curious, what's wrong with size_t loop indices? I always thought that was the most correct type for the job
Using ssize_t is pretty reasonable, and you're not going to overflow ssize_t for loop indices except in some very pathological cases on a 32 bit architecture.
If the arithmetic argument doesn't convince you, here's another one: write a correct loop (using size_t) which traverses your array in reverse order. Here is a broken example which would be fine with ssize_t:
for (size_t ii = len - 1; ii >= 0; --ii) {
}One correct way would be
for (size_t i = len; i > 0; --i) {
// use i-1 as the array index
}
or, size_t i = len
while (i-- > 0) {
// use i as the array index
}Edit: I guess that wasn't the point of your example (that it may not be easily recognisable as a bug?)