Re:“C is quirky, flawed, and an enormous success” – Dennis R...
by skitter on Sunday July 09, 2023 @10:34AM
(#36654766)
Not quite what I was getting at: On an implementation with 32-bit ints, the code is valid – the values get promoted to 32 bit, added and then truncated to 16 bit. Yet on a platform with 16-bit ints (and microchips & unusual platforms is a frequently stated reason for using C), the addition overflows and result in UB.
Luckily most other languages haven't decided to copy C's implicit promotion rules & target-dependant integer sizes.
Luckily most other languages haven't decided to copy C's implicit promotion rules & target-dependant integer sizes.