The condition of assert changes a variable, which does not happen when assertions are off
What it finds
assert(n-- > 0) or assert(p = next(p)): with NDEBUG defined, assert and its argument disappear, and with them the change, so the program behaves differently in a release build. Some projects define an assert of their own that is never turned off, so this is not a default rule.
From the rule's source, assert_side_effect.rs.
#include <assert.h> int next(int *p); void check(int n, int *p){ assert(n-- > 0);tx0 reports: this change happens only while assertions are on assert(n > 0); assert(next(p) == 0);} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:assert-side-effect" = "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/c:assert-side-effect] reason="..."tx0 explain tx0/c:assert-side-effect shows the same in the terminal. Found a false positive? Report it.