http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49251
Summary: [C++0x][parameter pack expanding] unused parameter
warning with unpacking empty tuples
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: trivial
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
#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. )