Yea so overflow/underflow are a problem with signed integers, not unsigned ones. Promotion rules might be the only candidate for hidden complexity here I guess
First, there is no integer underflow. Underflow is only possible with floating point numbers.
Second, signed integer overflow is always undefined behavior whereas unsigned integer overflow is ok (= modulo behavior).
The actual issue I was describing is about accidentally converting a negative (signed) integer to an unsigned integer, which completely changes its value. This is not a problem with signed or unsigned integers per se, but rather with the implicit conversions between these types. IMO this should have never been allowed in the first place.
spacechild1|6 months ago
Second, signed integer overflow is always undefined behavior whereas unsigned integer overflow is ok (= modulo behavior).
The actual issue I was describing is about accidentally converting a negative (signed) integer to an unsigned integer, which completely changes its value. This is not a problem with signed or unsigned integers per se, but rather with the implicit conversions between these types. IMO this should have never been allowed in the first place.