3 ms·
> Which can be avoided if you remember that hazard is there. This is true, but it could be argued that it's harder to avoid signed integer overflow in C/C++ th
by TazeTSchnitzel 3y ago
> Which can be avoided if you remember that hazard is there.
This is true, but it could be argued that it's harder to avoid signed integer overflow in C/C++ than it is to avoid buffer overflows: you often don't know what types you're working with, due to the usual arithmetic conversions and integer promotions, and checking whether an overflow will occur without causing an overflow is difficult in itself. It's kind of uniquely awful in this respect, basically every other popular language has a more practical integer programming model.
- celrod 3y agoI like integer overflow being UB. Makes it easier to check for by enabling a sanitizer. With it being defined as wrapping, it would be illegal for overflow to cause a runtime trap. Of course, rust mandates the trap on debug builds, which is a fine approach too.