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

This might be a variation of BUG41211
Reproduction on compiler explorer:

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

#include <type_traits>
#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;
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

Reply via email to