[llvm-bugs] [Bug 42958] New: -Wunused-lambda-capture too strict with 'this'

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 10 15:51:29 PDT 2019


            Bug ID: 42958
           Summary: -Wunused-lambda-capture too strict with 'this'
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rogero at howzatt.demon.co.uk
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Compiler Explorer https://godbolt.org/z/57PJFq

When compiled with -Wunused-lambda-capture clang gives:
warning: lambda capture 'this' is not used

However, it is used *implicitly* by the call to impl() and removal causes an

--- example.cpp ---
#include <functional>

void doit(std::function<void(int)>){}

struct S
  template <typename T>
  void impl(T, int) {}

  template <typename T>
  void run(T t)
    doit([t, this](auto r) {
      impl(t, r);

int main()
  S s;
--- ends ---

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190810/04d77450/attachment.html>

More information about the llvm-bugs mailing list