Expressions and statements
ES.103
Don't overflow
Reason
Overflow usually makes your numeric algorithm meaningless. Incrementing a value beyond a maximum value can lead to memory corruption and undefined behavior.
Example, bad
int a[10];
a[10] = 7; // bad, array bounds overflow
for (int n = 0; n <= 10; ++n)
a[n] = 9; // bad, array bounds overflow
Example, bad
int n = numeric_limits<int>::max();
int m = n + 1; // bad, numeric overflow
Example, bad
int area(int h, int w) { return h * w; }
auto a = area(10'000'000, 100'000'000); // bad, numeric overflow
Exception
Use unsigned types if you really want modular arithmetic.
Alternative: For critical applications that can afford some overhead, use a range-checked integer and/or floating-point type.
Enforcement
???