There is no real signaling overflow for integers in current processors. Thus, on 32-bit processors, integer arithmetic is performed at a modular level of 2 ^ 32 at the bit level. When you add two int -s and an βoverflowβ occurs, the overflow (or carry) bit is set to some state register (and the arithmetic operation is performed by the 2 ^ 32 module). If (as is usually the case) no machine instruction checks the overflow status bit, nothing happens.
Thus, the control flow will not change due to overflow (usually it will change when dividing by zero, for example, with the SIGEMT signal).
If you want to port an overflow case in C, you can check for example. that the sum of two positive int -s remains positive. (if it is negative, an overflow has occurred).
You may also be interested in bignums , for example. use the gmp library. You can also use <stdint.h> and gently use int32_t and int64_t with explicit clicks. Finally, you can (as most coders do), ignore this problem.
NB: As Jonathan remarked, you might get into undefined behavior or unspecified behavior . If you really care, use bonuses. However, you may not care at all.
source share