4 ms·
Integer promotion seems to be the source of many signed integer overflow UB. Why does C have it? Does integer promotion ever have a good part?
by mjs01 5mo ago
Integer promotion seems to be the source of many signed integer overflow UB. Why does C have it? Does integer promotion ever have a good part?
- saagarjha 5mo agoYes, it simplifies a lot of code that would otherwise be littered with casts.
- peterfirefly 5mo agoCould be fixed by having a nicer casting syntax (like Rust) or by not having so damn many scalar types that are used in practice. "Explicit casts only" worked fine in Modula-2, which doesn't have as many scalar types.
- saagarjha 5mo agoYeah most modern languages settle on having fewer types that are used most of the time and don't require as many casts.