Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22016

Is there a `clang++:-Wunused-lambda-capture` equivalent warning in/being developed for GCC?

$
0
0

Background

I sometimes run into code that use the following dummy lambda-capture (instead of e.g. (void)x;, ... foo(int /* x */) or ... foo([[maybe_unused]] int x) in C++17) in order to remedy an unused variable warning:

void foo(int x){    [&x]{}();}

Now, this is not really a remedy, as it passes the warning over from the current scope to the lambda capture instead, but afaik, GCC has no diagnostic to flag this, whereas e.g. Clang (as of 5.0) emits the unused-lambda-capture warning, if activated.

$ clang++ -xc++ -std=c++11 -Wunused-lambda-capture - <<< "int main() { int x; [&x]{}(); }"<stdin>:1:23: warning: lambda capture 'x' is not used [-Wunused-lambda-capture]int main() { int x; [&x]{}(); }                      ^1 warning generated.

In GCC projects, I would if possible be able to catch constructs as the one above without resorting to Clang.

Question(s)

  • Is there indeed currently no equivalent for GCC?
  • If not, is that a feature that is currently planned to be implemented / currently being implemented?

Viewing all articles
Browse latest Browse all 22016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>