[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

Nikita Kniazev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 23 09:37:36 PDT 2020


nick added a comment.

> 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

> The combination of having an uninitialized variable and explicitly marking it unused like this seems to me like it would be unusual.

It could be a variable used exclusively inside an `assert` or some other conditionally no-op macro-function.


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