Unsigned Sizes: A Five Year Mistake
3 hours ago
- #C3-language
- #systems-programming
- #signed-vs-unsigned
- C3 is transitioning from unsigned to signed sizes as the default for types and lengths.
- Unsigned sizes lead to common bugs like infinite loops, broken comparisons, and unsafe implicit conversions.
- Using signed sizes simplifies code, reduces the need for casts, and makes errors easier to detect.
- Signed integers have safer boundaries compared to unsigned, with overflow producing more obvious negative numbers.
- The change, nicknamed 'szmageddon', renames the signed size type to 'sz' to promote its use over unsigned 'usz'.