An argument with a side effect is evaluated more than once by the macro it is given to

tx0/c:macro-repeats-side-effectdefaultwarningreliability/logicdepth fastbug

What it finds

MAX(i++, n) where MAX uses its argument twice: the increment, decrement or assignment written once in the argument runs as often as the macro's expansion evaluates the argument, and in an unsequenced expansion the behaviour is undefined.

``c #define SQUARE(x) ((x) * (x)) area = SQUARE(side++); // side is incremented twice ``

The rule needs the translation-unit view of the file, so it knows the macros of the headers too. It reports an operator with a side effect that is written once in the file and that the expansion puts in place at least twice where it is evaluated; a copy inside sizeof, typeof, _Alignof, a builtin that takes types or the controlling expression of _Generic is not evaluated, as in macros written to evaluate their argument once.

From the rule's source, macro_repeats_side_effect.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/c:macro-repeats-side-effect" = "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:macro-repeats-side-effect] reason="..."

tx0 explain tx0/c:macro-repeats-side-effect shows the same in the terminal. Found a false positive? Report it.