▲ | flykespice 14 hours ago | ||||||||||||||||||||||||||||
There is no easy way out when you're working with C: either you handle all possible UB cases with exhaustive checks, or you move on to another language. (TIP: choose the latter) | |||||||||||||||||||||||||||||
▲ | uecker 11 hours ago | parent | next [-] | ||||||||||||||||||||||||||||
For signed overflow you can just turn on the sanitizer in trapping mode. Exhaustive checks is also not that terrible. | |||||||||||||||||||||||||||||
▲ | jeroenhd 13 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||
Very few programming languages default to checked increments. Most Rust or Java programmers would make the same mistake. Writing a function to do a checked addition like in other languages isn't exactly difficult, either. | |||||||||||||||||||||||||||||
|