Re:Almost Always Unsigned
by whattheactualf3 on Sunday January 02, 2022 @07:40AM
(#29768255)
Here's an example:
I would argue that there is plenty of code like that in the wild. It looks innocent and harmless but it gives a completely surprising result.
[ Parent
| on HN ]
If you ignore the compiler warning. This is trivial for the compiler to detect.
only in the most trivial cases
Re:Almost Always Unsigned
by captainmuon on Sunday January 02, 2022 @05:07PM
(#29774511)
I don't understand why the programming language can't promote the temporary to a larger signed int. Of course you can't change it in C anymore, but its like this in most languages. But you rarely ever want unsigned modulo arithmetic here (and if you do it should be a special syntax).
Re:Almost Always Unsigned
by virtualritz on Sunday January 02, 2022 @09:25AM
(#29768901)
-Werror