intprops module consists of an include file
that defines several macros useful for testing properties of integer
Integer overflow is a common source of problems in programs written in C and other languages. In some cases, such as signed integer arithmetic in C programs, the resulting behavior is undefined, and practical platforms do not always behave as if integers wrap around reliably. In other cases, such as unsigned integer arithmetic in C, the resulting behavior is well-defined, but programs may still misbehave badly after overflow occurs.
Many techniques have been proposed to attack these problems. These include precondition testing, wraparound behavior where signed integer arithmetic is guaranteed to be modular, saturation semantics where overflow reliably yields an extreme value, undefined behavior sanitizers where overflow is guaranteed to trap, and various static analysis techniques.
Gnulib supports wraparound arithmetic and precondition testing, as these are relatively easy to support portably and efficiently. There are two families of precondition tests: the first, for integer types, is easier to use, while the second, for integer ranges, has a simple and straightforward portable implementation.
|• Arithmetic Type Properties:||Determining properties of arithmetic types.|
|• Integer Bounds:||Bounds on integer values and representations.|
|• Wraparound Arithmetic:||Well-defined behavior on signed overflow.|
|• Integer Type Overflow:||General integer overflow checking.|
|• Integer Range Overflow:||Integer overflow checking if bounds are known.|