Bug ID: 41211
           Summary: -Wunused-lambda-capture too strict with variadic usage
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs

Reproduction on compiler explorer:
error: lambda capture 'i' is not used [-Werror,-Wunused-lambda-capture]

In the example below, we get a compiler warning on 'unused' lambda capture 'i'.
when changing the call to f from 'f<>' to 'f<int>', the warning goes away.
When removing the capture, as suggested, we get: error: variable 'i' cannot be
implicitly captured in a lambda with no capture-default specified

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

template <typename T>
int g(int i);

template<typename ...T>
auto f(int i)
    return [i](){ return h(g<T>(i)...); };

int main()
    return f<>(42)();
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