A variable is changed twice, or changed and read, in one expression without a sequence point between
What it finds
i = i++, a[i] = i++ or f(n++, n): the order in which the parts of an expression are evaluated is not fixed, so changing a variable twice, or changing it and reading it elsewhere in the same expression, is undefined behavior; compilers give different results.
The expression must be a whole expression statement, return value, condition or initializer without &&, ||, ?: or the comma operator, which order their operands. Only plain variables the file declares count; the value on the right of an assignment may read the variable it assigns, as in x = x + 1. An expression that calls a function the file does not declare, which may be a macro, is left alone.
From the rule's source, unsequenced_modification.rs.
int f(int a, int b); int order(int i, int *a, int n){ int j = 0; i = i++;tx0 reports: i is changed and used again in the same expression a[n] = n++;tx0 reports: n is changed and used again in the same expression j = f(j++, j);tx0 reports: j is changed and used again in the same expression i = i + 1; a[n++] = 0; j = (n > 0) ? n++ : n; return i;} 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:
[rules]
"tx0/c:unsequenced-modification" = "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:unsequenced-modification] reason="..."tx0 explain tx0/c:unsequenced-modification shows the same in the terminal. Found a false positive? Report it.