[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function
Hans Wennborg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 23 11:48:36 PDT 2020
hans added a comment.
In D79895#2109414 <https://reviews.llvm.org/D79895#2109414>, @nick wrote:
> > I feel like doing interprocedural analysis for this is overkill. What is the benefit of boost::ignore_unused(foo); rather than the more common (void) foo;? Any examples?
>
>
>
> > I haven't seen boost::ignore_unused before. In my experience, the idiomatic way of ignoring an unused variable in C/C++ is to cast it to void, as Arthur said.
>
> This is a weak argument to have false positives, don't you agree? You may have not seen it, but it exists and is used: https://github.com/search?q=%22boost%3A%3Aignore_unused%22+NOT+%22Boost+Software+License%22&type=Code
There are plenty of warnings which have false positives on non-idiomatic code though. The question is how common this pattern of using a function to ignore an unused variable is. We didn't see it in the code bases I work with, so is boost a special case, or an example of a common practice? If it's just boost, fixing the code seems better (it will compile faster too).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79895/new/
https://reviews.llvm.org/D79895
More information about the cfe-commits
mailing list