Arithmetic on int constants overflows the range of int

tx0/cpp:constant-overflowdefaultwarningreliability/arithmeticdepth fastbug, cwe-190

What it finds

365 * 24 * 60 * 60 * 1000: every operand is an int, so the product is computed in int and overflows before it is assigned to anything wider, which is undefined behavior and in practice wraps to a wrong value. A suffix such as 1000LL on one operand makes the arithmetic wide enough.

Only sums, differences and products of decimal literals without suffixes count, whose type is int whatever the platform; the expression reported is the first one whose operands fit in int and whose result does not.

From the rule's source, constant_overflow.rs.

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/cpp:constant-overflow" = "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/cpp:constant-overflow] reason="..."

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