std::remove, std::remove_if or std::unique is called for its effect, which leaves the container's size unchanged

tx0/cpp:remove-without-erasedefaulterrorreliability/logicdepth fastbug

What it finds

std::remove(v.begin(), v.end(), x); moves the kept elements to the front and returns where they end; the container keeps its size and the elements after that point are left in an unspecified state. The result goes to erase: v.erase(std::remove(...), v.end()), or std::erase(v, x) since C++20.

From the rule's source, remove_without_erase.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:remove-without-erase" = "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:remove-without-erase] reason="..."

tx0 explain tx0/cpp:remove-without-erase shows the same in the terminal. Found a false positive? Report it.