User account creation filtered due to spam.

Bug 49251 - [C++0x][parameter pack expanding] unused parameter warning with unpacking empty tuples
Summary: [C++0x][parameter pack expanding] unused parameter warning with unpacking emp...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 trivial
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
: 49339 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-06-01 08:23 UTC by Takaya Saito
Modified: 2011-08-29 12:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-06-15 17:31:05


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Takaya Saito 2011-06-01 08:23:50 UTC
#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. )
Comment 1 Jason Merrill 2011-06-15 18:06:43 UTC
*** Bug 49339 has been marked as a duplicate of this bug. ***
Comment 2 Jason Merrill 2011-06-16 22:09:00 UTC
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
Comment 3 Jason Merrill 2011-06-17 01:06:46 UTC
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
Comment 4 Jason Merrill 2011-06-17 01:10:56 UTC
Fixed for 4.6.1.
Comment 5 Jonathan Wakely 2011-08-29 12:39:36 UTC
*** Bug 50224 has been marked as a duplicate of this bug. ***