https://bugs.llvm.org/show_bug.cgi?id=42958

            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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

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
error.

--- 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;
  s.run(1);
}
--- ends ---

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to