An overflow is tested by comparing a + b with a, which relies on wrapping that signed integers and pointers do not do

tx0/c:overflow-check-relies-on-wrapdefaultwarningreliability/arithmeticdepth fastbug, cwe-190

What it finds

if (len + n < len) with a signed len, or if (p + n < p): signed overflow and pointer arithmetic past the object are undefined, so the compiler may assume the sum is never smaller and remove the test. Comparing n with the room left, as in n > INT_MAX - len, tests the same without overflowing.

The variable must be declared in the file with a signed integer or a pointer type.

From the rule's source, overflow_check_relies_on_wrap.rs.

Example from the rule's tests
int fits(int len, int n){  if (len + n < len)tx0 reports: this test relies on signed arithmetic on len wrapping, which is undefined    return 0;  unsigned u = (unsigned)len;  return u + 1u < u;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/c:overflow-check-relies-on-wrap" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/c:overflow-check-relies-on-wrap] reason="..."

tx0 explain tx0/c:overflow-check-relies-on-wrap shows the same in the terminal. Found a false positive? Report it.