-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugprone-sizeof-expression new false positives in pre20240924 clang-tidy, not reported by pre20240917 #110551
Comments
#106061, CC @whisperity FYI |
Hah, the parentheses are a very good idea to silence these, and to be fair, I don't remember us actually planning that some parens here and there will silence the warning! Deciding whether something is really a false positive is always a hard thing to do. Unfortunately, the code above, at least from what is visible in the report, is still suspicious, as per SEI-CERT ARR39-C. "Do not add or subtract a scaled integer to a pointer", which the improvement landed in #106061 had as a goal to match. Now, a code or a project can always decide that they want one or more rules to not apply to them. The underlying issue here is that the connection that |
Thanks @whisperity for the CERT link. Good resource. FWIW, ARR39-C doesn't seem to anticipate or address divisive scaling in this construct, and is tolerant of division in a related construct ( This is a common code pattern and not inherently dangerous. It would be a shame to see projects disable For our part we've just patched out the problematic code, allowing us to keep it globally active:
|
We're seeing a slew of new false positives of this form:
These weren't reported by
pre20240917
.A workaround with
pre20240924
is to parenthesize thusly:These parentheses should not be necessary -- the
/
has higher precedence than the+
and the incumbent code pattern is quite common.The text was updated successfully, but these errors were encountered: