https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98706
Bug ID: 98706
Summary: spurious unused-set-but-not-used when a parameter pack
is empty
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
Short test case:
template <typename... T>
constexpr auto f(T... ts) {
auto id = [](auto x){ return x; };
return (id(ts) + ... + 0);
}
static_assert(f() == 0);
Emits:
<source>: In instantiation of 'constexpr auto f(T ...) [with T = {}]':
<source>:7:17: required from here
<source>:3:10: warning: variable 'id' set but not used
[-Wunused-but-set-variable]
3 | auto id = [](auto x){ return x; };
| ^~
Compiler returned: 0
This is basically bug #56958, but the commentary there suggests that the
warning is okay and I want to be clear that the warning is a false positive
here. The warning persists even if a different instantiation of 'f' uses 'id'.