3 ms·
There is a mode of UBSan that would catch it, but I don't think you could run it on SHA code because that uses unsigned overflow for the hash. Basically, this
by astrange 4y ago
There is a mode of UBSan that would catch it, but I don't think you could run it on SHA code because that uses unsigned overflow for the hash.
Basically, this is why you shouldn't use unsigned types unless you explicitly want them to overflow.
- nyberg 4y agoThis is rather sad that one must give up the range and add the signed range just to avoid overflow bugs. Is there no way to make overflow not the default and instead trap unless one uses `add_wrap()` or `add_no_wrap()` in case it's not default?
- astrange 4y agoThere is overflow-checking math in GCC/Clang and standardized in C23, but I'm not sure if there's anything opt-out. If there is, I don't know how to write it.
- deleted 4y ago[deleted]