[llvm-bugs] [Bug 41212] New: -Wunused-lambda-capture too strict with double variadic usage
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Mar 23 09:57:59 PDT 2019
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: unassignedclangbugs at nondot.org
Reporter: jvapen at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190323/deb03da4/attachment-0001.html>
More information about the llvm-bugs
mailing list