Comment Comment by pornel Would you consider adding a built-in way to safely multiply two numbers?Numeric overflows in things like calculation of buffer sizes can lead to vulnerabilities.Signed overflow is UB, and due to integer promotion signs creep in unexpected places.It's not trivial to check if overflow happened due to UB rules. A naive check can make things even worse by "proving" the opposite to the optimizer.And all of that is to read one bit that CPUs have readily available. parent pornel 6 years ago
Numeric overflows in things like calculation of buffer sizes can lead to vulnerabilities.
Signed overflow is UB, and due to integer promotion signs creep in unexpected places.
It's not trivial to check if overflow happened due to UB rules. A naive check can make things even worse by "proving" the opposite to the optimizer.
And all of that is to read one bit that CPUs have readily available.