FAILURE MAP
← Case archive

FA-5371 / Integer arithmetic / Open access

Unsigned saturating addition · case 01

Overflow wraps instead of saturating.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Overflow wraps instead of saturating.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return min((1<<bits)-1, a+b)

Unsuccessful approach: The saturation ceiling includes an unrepresentable endpoint.

Case contract

Integer arguments; denominators, steps, moduli, and bit widths are positive. Unsigned word inputs fit the specified width except where masking is explicitly the operation. Sequence sizes are nonnegative. a and b are nonnegative; cap their sum at 2**bits-1. Exact operational definition: min((1<<bits)-1, a+b)

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Integer mathematics results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, bits):
    return (a+b)% (1<<bits)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (250, 10, 8)', solve(*(250, 10, 8)), 255)
check('fixture 2: (2, 3, 8)', solve(*(2, 3, 8)), 5)
check('fixture 3: (0, 0, 1)', solve(*(0, 0, 1)), 0)
check('fixture 4: (1, 1, 1)', solve(*(1, 1, 1)), 1)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: (250, 10, 8)4255Failed
fixture 2: (2, 3, 8)55Passed
fixture 3: (0, 0, 1)00Passed
fixture 4: (1, 1, 1)01Failed

SHA-256 / d38aaef3ef5fc837ed7f011531085828d9d87b296a137b55537f382be4605c45

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, bits):
    return min(1<<bits, a+b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (250, 10, 8)', solve(*(250, 10, 8)), 255)
check('fixture 2: (2, 3, 8)', solve(*(2, 3, 8)), 5)
check('fixture 3: (0, 0, 1)', solve(*(0, 0, 1)), 0)
check('fixture 4: (1, 1, 1)', solve(*(1, 1, 1)), 1)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: (250, 10, 8)256255Failed
fixture 2: (2, 3, 8)55Passed
fixture 3: (0, 0, 1)00Passed
fixture 4: (1, 1, 1)21Failed

SHA-256 / fc7816ea01487808b789445c3ec95b600399f7adccf42466d1129e006dcd49e7

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, bits):
    return min((1<<bits)-1, a+b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (250, 10, 8)', solve(*(250, 10, 8)), 255)
check('fixture 2: (2, 3, 8)', solve(*(2, 3, 8)), 5)
check('fixture 3: (0, 0, 1)', solve(*(0, 0, 1)), 0)
check('fixture 4: (1, 1, 1)', solve(*(1, 1, 1)), 1)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: (250, 10, 8)255255Passed
fixture 2: (2, 3, 8)55Passed
fixture 3: (0, 0, 1)00Passed
fixture 4: (1, 1, 1)11Passed

SHA-256 / 77c54d60b5429e2294820dda279a22101fde2a51d0b182e6b9beb6c440096999

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:37:48.632177+00:00.

Case digest / 6ea6968f33832b7f042b96bec554c417747c4852c05f08aa35baa7340a6f14fa