Bug 51507 - [C++0x] Function parameter pack doesn't use in template-argument-list
Summary: [C++0x] Function parameter pack doesn't use in template-argument-list
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.2
: P3 normal
Target Milestone: 4.7.0
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-12 02:28 UTC by Koichi Oyama
Modified: 2011-12-23 22:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-12-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Koichi Oyama 2011-12-12 02:28:48 UTC
Following code cannot compile with gcc:

  template<typename ...>
  struct foo { typedef void type; };
  template<typename ...Ts>
  auto g(Ts ...ts)->
      typename foo<decltype(ts)...>::type
  {}
  int main() {
      g(42);
  }

Error:

  test1.cpp: In function 'int main()':
  test1.cpp:8:9: error: expansion pattern 'int' contains no argument packs
  test1.cpp:8:9: error: no matching function for call to 'g(int)'
  test1.cpp:8:9: note: candidate is:
  test1.cpp:4:6: note: template<class ... Ts> typename foo<decltype (ts)...>::type g(Ts ...)

I think decltype(fs()) is a valid template-argument pattern for foo.
Comment 1 Jason Merrill 2011-12-23 22:00:21 UTC
Author: jason
Date: Fri Dec 23 22:00:13 2011
New Revision: 182668

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182668
Log:
	PR c++/51507
	* search.c (at_function_scope_p): Also check cfun.
	* pt.c (tsubst_pack_expansion): Check it instead of
	cp_unevaluated_operand.
	(instantiate_template_1): Clear current_function_decl.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic121.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/search.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-12-23 22:10:33 UTC
Fixed for 4.7.