Re:Almost Always Unsigned
by quelsolaar on Sunday January 02, 2022 @05:36AM
(#29767564)
Interesting perspective. I dont have the same experience. To me a wraping 32 bit index on a 64bit machine is much more likely to seg fault if it reads 4 billion values forward, rather than a few bytes backwards and therefore i find unsigned index wrapps to be easier to debug. In all fairness wrapping indicies are an extremely rare bug for me, so i cant say i have much experience debugging it.
[ Parent
| on HN ]
I think when you use a variable that can have values in the range of millions, it's prudent to use 64-bit types and not 32-bit unless you are very much memory-constrained. And I've never seen a 64-bit signed variable overflow.
> In all fairness wrapping indicies are an extremely rare bug for me, so i cant say i have much experience debugging it.
Do you run your code with -fsanitize=undefined -fsanitize=integer ?
Re:Almost Always Unsigned
by quelsolaar on Sunday January 02, 2022 @09:59AM
(#29769198)
No I do not. I run ISO conformant C without options.