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

tx0/cpp:overflow-check-relies-on-wrapstrictwarningreliability/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.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

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

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/cpp:overflow-check-relies-on-wrap] reason="..."

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