-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
Remove unnecessary null pointer checks #7432
Comments
At least a |
Would you also like to update another software library? |
In Bitcoin Core we believe in belt-and-suspenders checks. A small change to the code can turn a 'unnecessary' NULL pointer check into the only thing that prevents a horrible security issue. Checking, even though not strictly necessary, may add some robustness to the API. Also it may be hard to prove that a check is unnecessary, evaluating the code paths is a lot of review work while there are tons of more serious issues. So let's just leave this as it is. If you can quantify that it saves time in a critical path (say an inner loop that is executed millions of times), feel free to remove an unnecessary check, but don't do so indiscriminately. |
Do you imagine any special case for the eventual handling of C++ compilers with a standard-incompliant implementation of the delete operator? |
Sure, if you encounter the code
Then, according to the C++ standard, you can replace it with
But don't do so if there is more code in the |
Why did you close this issue already? |
I don't see this as a serious issue. |
I suggested just another small software optimisation here. |
Please no bikeshedding on avoidable pointer checks. No need to create an issue for that (create a PR instead if you want to improve things). |
Isn't the compiler taking care of such? |
An extra null pointer check is not needed in functions like the following.
I reported this issue for another evolving software before.
The text was updated successfully, but these errors were encountered: