r/ProgrammingLanguages • u/Nuoji C3 - http://c3-lang.org • May 03 '26
Blog post Unsigned Sizes: A Five Year Mistake
https://c3-lang.org/blog/unsigned-sizes-a-five-year-mistake/
91
Upvotes
r/ProgrammingLanguages • u/Nuoji C3 - http://c3-lang.org • May 03 '26
View all comments
Show parent comment
3
u/matthieum May 05 '26
This is not the question asked, unfortunately.
The question asked is to justify why unsigned should exist in the first place, and specifically, whether unsigned really pull their weight.
Signed integers are necessary for general arithmetic, anyway. Is adding unsigned integers on top really worth it?
I'm not convinced.
I mostly see people adding them because "that's how it's always been", but I rarely see a compelling costs/benefits analysis.
We don't. That's a problem that is specific to C and C++, it's not a universal property of signed vs unsigned.
GCC and Clang both offer
-fwrapv, which the Linux kernel uses, to have wrap-around for signed arithmetic too.Rust offers either panic on wrap or wrap-around (your choice).
Java only wraps around.
In my experience they're an issue for everyone...
Yes, I explicitly mentioned it.
Overflow is still a risk, however: