Re:size_t-to-int vulnerability in Linux’s filesystem layer
by phkahler on Tuesday July 20, 2021 @03:19PM
(#27897988)
>> there are often times where it makes sense to use the platform's "natural" word sizes
In those cases we probably don't care about the full range of the larger types, so it doesn't hurt to use the smallest type for a range of expected values. If it does make a difference, the program will behave differently when compiled on a different arch or even a different compiler.
But maybe "generally" instead of "always". OTOH even I am guilty of using an int to loop over an array.
"Always" is a strong way of putting it, there are often times where it makes sense to use the platform's "natural" word sizes (which is the entire point of having `int` `long` `long long` etc.)