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, GCC’s -ftrapv option, GCC’s no-undefined-overflow branch, the as-if infinitely ranged (AIR) model implemented in Clang, saturation semantics where overflow reliably yields an extreme value, the RICH static transformer to an overflow-checking variant, and special testing methods. For more information about these techniques, see: Dannenberg R, Dormann W, Keaton D et al., As-if infinitely ranged integer model, 2nd ed., Software Engineering Institute Technical Note CMU/SEI-2010-TN-008, April 2010.
Gnulib supports the precondition testing technique, as this is easy to support portably. There are two families of precondition tests: the first, for integer ranges, has a simple and straightforward implementation, while the second, for integer types, is easier to use.
|• Integer Type Determination:||Whether a type has integer properties.|
|• Integer Bounds:||Bounds on integer values and representations.|
|• Integer Range Overflow:||Integer overflow checking if bounds are known.|
|• Integer Type Overflow:||General integer overflow checking.|