A copy constructor of a derived class does not copy its base class, which is default-constructed instead

tx0/cpp:copy-constructor-skips-baserecommendedwarningreliability/object-contractsdepth fastbug

What it finds

In Derived(const Derived &other) : member(other.member) {} the base class is missing from the initializer list, so it is built with its default constructor and the copy loses the base's state. Listing Base(other) copies it.

From the rule's source, copy_constructor_skips_base.rs.

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:

tx0.toml
[rules]
"tx0/cpp:copy-constructor-skips-base" = "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/cpp:copy-constructor-skips-base] reason="..."

tx0 explain tx0/cpp:copy-constructor-skips-base shows the same in the terminal. Found a false positive? Report it.