by masklinn · 10y ago · 0 comments
The good part being that you're warned at compile time, not when your 2^16 elements loop becomes a 2^32 elements loop.
Or if you do not make assumptions of the sizes of int, something that only bad programmers do.
No you'll have the exact problem I cited in that case.
> Or if you do not make assumptions of the sizes of int, something that only bad programmers do.
Requesting a specific data size is the exact opposite of making assumptions.
I can see how the type changing to a smaller one might cause problems, but I don't see how IshKebab's example could happen without exploiting implementation specific overflow behavior.
INT_MAX (or INT_LEASTN_MAX for annathebannana's suggestion) doesn't require exploiting overflow behaviour, but going from 2^15 iterations to 2^31 or 2^61 iterations may be problematic.