[llvm-bugs] [Bug 41211] New: -Wunused-lambda-capture too strict with variadic usage

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 23 08:42:40 PDT 2019


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

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

Reproduction on compiler explorer: https://godbolt.org/z/hJHQui
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

t.cpp
-----
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)();
}

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/cbaa3dee/attachment.html>


More information about the llvm-bugs mailing list