https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85784
Bug ID: 85784 Summary: False positive with -Wunused-but-set-parameter Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: samueljlunt at gmail dot com Target Milestone: --- Given the following functions: #include <utility> #include <tuple> template <typename... Args> auto foo(Args&&...) {} template <typename... Args, std::size_t... Indexes> auto bar(std::tuple<Args&&...> args, std::index_sequence<Indexes...>) { return foo(std::forward<Args>(std::get<Indexes>(args))...); } template <typename... Args> auto bar(std::tuple<Args&&...> args) { return bar(std::move(args), std::index_sequence_for<Args...>{}); } A function call "bar()" will generate a -Wunused-but-set-parameter warning, while any call with at least one argument will not generate a warning. I am guessing that this has something to do with the fact that when "...Args" is empty, "foo(std::forward<Args>(std::get<Indexes>(args))...)" is expanded to "foo()", and "std::tuple<> args_" is not used. However, I don't see why this would trigger "-Wunused-but-set-parameter" (since no assignment takes places here) instead of "-Wunused". Either way, this seemed like a false positive to me, since in the template function, args is used. It is only in a specific instantiation of the template that it is not used. Also, I noticed making args an rvalue reference, i.e. bar(std::tuple<Args&&...>&& args, std::index_sequence<Indexes...>), silences the warning. Here is an example on godbolt.org illustrating the warning: https://godbolt.org/g/VaA979