A struct ends with an array of one element, used as an old form of flexible array
What it finds
struct msg { int len; char text[1]; }; allocated with room for more and indexed past the first element: an access beyond the declared length is undefined, and compilers that check bounds or optimize on them break it. A flexible array member, char text[];, says the same in standard C.
From the rule's source, one_element_trailing_array.rs.
struct message { int length; char text[1];tx0 reports: this one-element array at the end of the struct may be used as a flexible array}; 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/c:one-element-trailing-array" = "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/c:one-element-trailing-array] reason="..."tx0 explain tx0/c:one-element-trailing-array shows the same in the terminal. Found a false positive? Report it.