A semicolon right after the condition of an if is its whole body

tx0/cpp:empty-if-bodydefaultwarningreliability/control-flowdepth fastbug

What it finds

if (x == 1); followed by a block: the ; right after the condition is the whole body of the if, so the block after it runs whatever the condition.

Only a ; on the line of the condition, with no comment before it, counts, and only for an if without else. A condition with a call is left alone: if (write(...)); is a way of ignoring a result that the compiler warns about.

From the rule's source, empty_if_body.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:empty-if-body" = "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:empty-if-body] reason="..."

tx0 explain tx0/cpp:empty-if-body shows the same in the terminal. Found a false positive? Report it.