A std::string is built from c_str() of another string, which measures it again and drops the length
What it finds
std::string t = s.c_str(); and std::string(s.c_str()) copy s through a C string: the length is recomputed with strlen, and the copy stops at the first zero byte inside s. Copying s itself is shorter and correct. The fix removes .c_str().
From the rule's source, redundant_c_str_copy.rs.
Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/cpp:redundant-c-str-copy" = "note"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:redundant-c-str-copy] reason="..."tx0 explain tx0/cpp:redundant-c-str-copy shows the same in the terminal. Found a false positive? Report it.