-
Notifications
You must be signed in to change notification settings - Fork 164
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
Silence clang warning -Wtautological-pointer-compare #3005
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm investigating this would cause null-pointer warnings in our tool-chains - and if so if that can be avoided.
Investigating more I don't think that this is the correct solution, and would either just disable the check - or see if it can be weakened in some other way. The reason is that as far as I understand:
Note that Visual Studio C++ (2019 at least) has considered this - and I would say that most of these functions are part of the trust boundary: "If a function appears at a trust boundary, we recommend that you use the Pre_defensive annotation. The "defensive" modifier modifies certain annotations to indicate that, at the point of call, the interface should be checked strictly, but in the implementation body it should assume that incorrect parameters might be passed. In that case, In Pre_defensive is preferred at a trust boundary to indicate that although a caller will get an error if it attempts to pass NULL, the function body will be analyzed as if the parameter might be NULL, and any attempts to de-reference the pointer without first checking it for NULL will be flagged." |
OK, I updated the code to only silence the clang warning while not changing any nullptr checks. See here for the CI run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now.
Hmm... Actually it seems that disabling "-Wtautological-pointer-compare" only disables the warnings, but clang (and gcc) still optimizes away the null-pointer tests, which is kind of dangerous. |
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a commit with the compiler flag added for the autotools project (only added if the flag exists for the compiler)
See this CI run compared to the previous one.
Close #2109.