-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++11clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
| Bugzilla Link | 41211 |
| Version | 8.0 |
| OS | Windows NT |
| CC | @zmodem,@JVApen,@pepsiman,@zygoloid,@Weverything |
Extended Description
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', 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
int g(int i);
template<typename ...T>
auto f(int i)
{
return i{ return h(g(i)...); };
}
int main()
{
return f<>(42)();
}
run.sh
clang++ -std=c++17 -O3 -Wunused-lambda-capture -Werror t.cpp
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++11clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer