Re:size_t-to-int vulnerability in Linux’s filesystem layer
by ridiculous_fish on Tuesday July 20, 2021 @03:20PM
(#27897997)
usize should be Into<u64> iff usize is <= 64 bit.
usize is already on that hook: `0x100000000usize` will fail to compile in 32 bit, so you already risk compile errors when switching archs.
As it is I'm just writing `as u64` which is clearly worse.
All explicit conversions, more so fallible, are "frustrating in practice" especially when coming from a language without those foibles.
But given the semantics of usize/isize, it is perfectly reasonable, nay, a good thing, that they're considered neither widenings nor narrowings of other numeric types.