3 ms·
Either you need to restrict arithmetic to values which can’t overflow, or yes, you need to check for overflow manually. Note that you need to do those checks wi
by pansa2 6y ago
Either you need to restrict arithmetic to values which can’t overflow, or yes, you need to check for overflow manually. Note that you need to do those checks without actually triggering the overflow because once undefined behaviour is possible, all bets are off.
- dgellow 6y agoI see, so checking for the overflow flag wouldn't be good as you now have your program in an undefined state.
- deadbytes 6y agoWhen I looked into doing this before I think the ultimate issue was that the C specification doesn't even give you any way to check the overflow flag. So even if you knew your specific C implementation handled overflow properly there is no way to check the flag afterwards anyway.