#include <tuple> template< std::size_t... Indices > struct indices {}; template< class... Args > void sink( Args&&... ) {} template< class Tuple, std::size_t... Indices > void unpack_test( Tuple && t, indices<Indices...> ) { sink( std::get<Indices>(t)... ); } int main() { unpack_test( std::tuple<>(), indices<>() ); } ------------------------ This code, which is unpacking tuples, raises unused parameter warning: $ g++ -std=c++0x -Wunused-parameter bug.cc bug.cc: In instantiation of 'void unpack_test(Tuple&&, indices<Indices ...>) [with Tuple = std::tuple<>, unsigned int ...Indices = {}]': bug.cc:15:44: instantiated from here bug.cc:10:6: warning: unused parameter 't' [-Wunused-parameter] I've confirmed this behavior on following versions: 4.5.0 4.5.3 4.6.0 4.6-20110527 4.7-20110528 It can be avoided by using the parameter explicitly, like `(void)t;', but it's not always used. ( For example, it cannot be used for constexpr functions. )
*** Bug 49339 has been marked as a duplicate of this bug. ***
Author: jason Date: Thu Jun 16 22:08:57 2011 New Revision: 175119 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175119 Log: PR c++/49251 * semantics.c (finish_id_expression): Mark even dependent variables as used. Added: trunk/gcc/testsuite/g++.dg/cpp0x/variadic113.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c trunk/gcc/testsuite/ChangeLog
Author: jason Date: Fri Jun 17 01:06:42 2011 New Revision: 175130 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175130 Log: PR c++/49251 * semantics.c (finish_id_expression): Mark even dependent variables as used. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/variadic113.C Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/semantics.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Fixed for 4.6.1.
*** Bug 50224 has been marked as a duplicate of this bug. ***
#include <tuple> template< std::size_t... Indices > struct indices {}; template< class... Args > void sink( Args&&... ) {} template< class Tuple, std::size_t... Indices > void unpack_test( Tuple t, indices<Indices...> ) { sink( std::get<Indices>(t)... ); } int main() { unpack_test( std::tuple<>(), indices<>() ); } ------------------------ With the small change in the signature (notice passing `t` by value), is this warning acceptable? bug.cc: In instantiation of 'void unpack_test(Tuple, indices<Indices ...>) [with Tuple = std::tuple<>; long unsigned int ...Indices = {}]': bug.cc:15:44: required from here bug.cc:10:25: warning: parameter 't' set but not used [-Wunused-but-set-parameter] void unpack_test( Tuple t, indices<Indices...> ) { ^ Observed with various versions from 4.4.7 to 9.0.0 201810. Not observed with Clang.