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
1
u/EggplantExtra4946 May 08 '26
So a negative size is not a valid size which is what I said.
It's more a problem for 32bit sizes. If you happens to overflow an unsigned size/index it will wrap to 0 and stay in bounds, with a signed 32bit if you only have 31 bits available for the size (2GB) and if you overflow the sign in principle you should have an invalid size (negative) except that size/references are casted to unsigned so it could access 2GB of memory after the end of the buffer.
Using a conditional jump explcitly designed to check overflows is better and faster than other alternatives. I don't see why new languages should not take advantage of this cpu capability.
I didn't say that it all operations should have an implicit overflow check, I'm saying there should the primitive available to allow the user to manually check wether an overflow happened or not. Like this https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html but builtin.
Bullshit. You yourself agreed that it's harder to understand and like I said, this is one the main classes of vulnerabilties and they happen all the time.
Sorry but that's not good enough, I would prefer to avoid programs written by lazy developpers and I won't allow them to touch to my code. Programming requires precision, writing correct programs even more so.