Better handling of integer wraparound in the kernel
Better handling of integer wraparound in the kernel
Posted Feb 2, 2024 18:10 UTC (Fri) by anton (subscriber, #25547)Parent article: Better handling of integer wraparound in the kernel
This article uses an unfortunate mixture of Cook's unfortunate terminology and something else (maybe something like the terminology below). Here's an attempt at something better:
There are the following overflow conditions:
- signed overflow (called "overflow" by Cook)
 - unsigned overflow (called "wraparound" by Cook)
 
There are the following common behaviours on an overflow:
- wraparound (the result is the number in the target type that is congruent with the mathematical result modulo 2^b)
 - trapping
 - saturating (used for DSP applications)
 - undefined (the compiler does whatever it likes)
 
           