-
Notifications
You must be signed in to change notification settings - Fork 12k
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-unused-return-value
warns about stream insertion operator (operator<<
)
#85913
Comments
@llvm/issue-subscribers-clang-tidy Author: Oliver Stöneberg (firewave)
If you enable the check to warn about all unused returns values by setting `bugprone-unused-return-value.CheckFunctions` `::.*` it will also report the unchecked usage of `operator<<`.
The following are all common code which is regularly unchecked. So I think it might sense to not warn about these.
It should still be reported for the extraction operator as it might indicate actual issues:
In this case the extraction fails and you need to check the result. See https://godbolt.org/z/KzPor3hMK. That could be a dedicated check though and this check could just ignore both of them. CC @HerrCai0907 |
I don't think it is a good idea to ignore |
The checker could easily check the return type of |
(This comment was edited, because I realized that I misunderstood the issue.)
I assumed that the issue happens with the default behavior of the checker, and not after a custom override that explicitly activates warnings on all unused return values. I'd say that here the behavior of Clang-Tidy is 100% correct: if the user specifies I don't think that using the wildcard |
Agree. The reason I disable the operator overloading for "+=", "-=" style things is that iIn the common sense, there is no ambiguity in these operators. But for "<<", unfortunately not. |
See danmar/cppcheck#6673 for some context why/how I (ab)use this check. |
If you enable the check to warn about all unused returns values by setting
bugprone-unused-return-value.CheckFunctions
::.*
it will also report the unchecked usage ofoperator<<
.The following are all common code which is regularly unchecked. So I think it might sense to not warn about these.
It should still be reported for the extraction operator as it might indicate actual issues:
In this case the extraction fails and you need to check the result. See https://godbolt.org/z/KzPor3hMK.
That could be a dedicated check though and this check could just ignore both of them.
CC @HerrCai0907
The text was updated successfully, but these errors were encountered: