Overview
- Bug Type:
- Integer overflow
- Category:
- Functional Logic & Control Flow
Definition
Arithmetic exceeds the numeric type's range, wrapping or truncating results.
How to fix Integer overflow?
Use checked arithmetic/wider types; validate inputs; guard allocations and counters; add property-based tests with extremes
Symptoms
Observable signs that may indicate Integer overflow:
- Negative or wraparound values after arithmetic.
- Allocation sizes overflow leading to tiny buffers.
- Counters reset unexpectedly at large values.
Example Errors:
- Signed integer overflow: undefined behavior
- ValueError: size must be non-negative
- ArithmeticException: integer overflow
