4 ms·
> Getting integer sizes right is important, and it's not just in cases where you're putting >2G on the heap. I prioritize on getting their values right :-). So
by jstimpfle 9y ago
> Getting integer sizes right is important, and it's not just in cases where you're putting >2G on the heap.
I prioritize on getting their values right :-). So far I have not encountered bugs due to my pretty uniform usage of int. But if they had to deal with allocations >2G, my programs would just die.
Yup, I make some exceptions as well, for example to measure time in microseconds, or to measure the size of very large streams. And of course I try to assert that all downcasts to int are valid, and that my integer operations don't overflow, etc. (why do CPUs still not support overflow exceptions?)
I'm pretty sure we could get rid of quite some historical baggage in terms of integer types. For example, I'm currently working on a network module, and there is a type socklen_t which is to indicate the size of a socket structure. I might be missing something, but to me there is no good reason not to use simply int.
- deleted 9y ago[deleted]