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

            Bug ID: 41212
           Summary: -Wunused-lambda-capture too strict with double
                    variadic usage
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: jva...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

This might be a variation of BUG41211
Reproduction on compiler explorer: https://godbolt.org/z/_Uanrt

In the example below, I get the following warning: lambda capture 't' is not
used [-Wunused-lambda-capture]

When removing the suggested 't', I get: error: variable 't' cannot be
implicitly captured in a lambda with no capture-default specified

t.cpp
-----
#include <type_traits>
#include<algorithm>
#include <optional>
#include <tuple>
#include <mutex>

template <typename T, typename TMutex>
struct W
{
    using mutex_type = TMutex;
    bool acquire();
};

template<typename ...T>
int convert(T && ... t);

struct S
   {
   template <typename TValue, typename TMutex>
   static TValue &v(W<TValue, TMutex> &);

   template <typename TValue, typename TMutex>
   static TMutex &m(const W<TValue, TMutex> &);
   };

template <typename... T>
auto acquire(T &... t)
      {
      auto locks = std::make_tuple(std::unique_lock<std::mutex>{ S::m(t),
std::defer_lock }...);

      auto dispatch = [&t...](auto &&... a)
         {
         static_assert(sizeof...(t) == sizeof...(a));
         return std::make_tuple(convert(S::v(t), std::move(a))...);
         };

      return std::apply(std::move(dispatch), std::move(locks));
      }

void f()
{
    W<int, std::mutex> a;
    acquire(a);
}

run.sh
------
clang++ -std=c++17 -O3 -Wunused-lambda-capture -Werror t.cpp

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

Reply via email to