A std::shared_ptr is created from this, which starts a second, independent owner count for the object
What it finds
std::shared_ptr<T>(this) makes a new control block; if another shared_ptr already owns the object, both delete it. A class derived from std::enable_shared_from_this gets a shared pointer to itself with shared_from_this().
From the rule's source, shared_ptr_from_this.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:
[rules]
"tx0/cpp:shared-ptr-from-this" = "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:shared-ptr-from-this] reason="..."tx0 explain tx0/cpp:shared-ptr-from-this shows the same in the terminal. Found a false positive? Report it.