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
2
u/Tasty_Replacement_29 Bau May 07 '26
Ah I missed this message sorry.
> You are being ridiculous.
No, I'm serious.
> And also there is a simpler way
Both options are not simple. The simple and obvious way is not working because of unsigned.
> James Gosling or not I doubt that this is true.
I do not doubt that this is true. I agree with James Gosling. It doesn't mean you have to agree, right. But you should not call me or James Gosling ridiculous if we don't agree. I don't call you ridiculous either.
> How are integer overflows in multiplications a problem about unsigned integers exactly
They are a problem because there is no way to detect them with unsigned: the result of the multiplication is still positive. With signed, if there is an overflow, then the result of the multiplication is negative, and you can detect that easily.
> Except that malloc malloc worked as expected. Again this has absolutely nothing to do with unsigned integers.
Sure, the problem was the usage of unsigned multiplication. That's my point: the problem wouldn't be there if size_t is signed. See also https://vorpus.org/blog/why-does-calloc-exist/
> Stop it with your hysteria. Unsigned integers are used, so what?
I'm not hysteric. The problem is that unsigned integers are used, yes.
> This so fucking stupid how is it even an solution?
This is not fucking stupid, it is a solution.
> You are being dishonnest about the problem of mixing signed and unsigned.
No, I am not.
> Clearly you think this is unsigned's fault, you never consider that signed integers are equally at fault.
Yes, the problem is unsigned integers in this case.
> I can't even see why you would use signed integers anyway.
Well, with signed integers you would be able to:
for (size_t i = length-1; i < length; i--) { array[i] }malloc(count * sizeof(int));