Bug 39863 - [c++0x] variadic templates : wrong error "mismatched argument pack lengths"
Summary: [c++0x] variadic templates : wrong error "mismatched argument pack lengths"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-23 12:22 UTC by Sylvain Pion
Modified: 2009-10-07 19:32 UTC (History)
2 users (show)

See Also:
Host: i386-apple-darwin9.6.0
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-10-07 17:55:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Pion 2009-04-23 12:22:21 UTC
The following code :

======================================
template <typename... T>
struct A {};

template <typename T, typename U>
struct S {};

template <typename... T, typename... U>
A< S<T, U>... > f(U... u)
{ return A< S<T, U>... >(); }

int main()
{
  f<int>(0.0);
}
============================================

compiled with g++ -std=c++0x on today's trunk, produces :

test_variadic_2.cpp: In function 'int main()':
test_variadic_2.cpp:13: error: mismatched argument pack lengths while expanding 'S<T, U>'
test_variadic_2.cpp:13: error: no matching function for call to 'f(double)'


I believe this is a bug, and the code should be accepted.
Comment 1 Sylvain Pion 2009-10-05 21:51:16 UTC
Same situation as of today's trunk.
Comment 2 Paolo Carlini 2009-10-05 22:22:14 UTC
Let's CC Jason...
Comment 3 Jason Merrill 2009-10-07 18:56:54 UTC
Subject: Bug 39863

Author: jason
Date: Wed Oct  7 18:56:39 2009
New Revision: 152537

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152537
Log:
	PR c++/39863
	* pt.c (tsubst_pack_expansion): Don't do anything now if we
	have incomplete packs of different lengths.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic95.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Jason Merrill 2009-10-07 19:32:18 UTC
Subject: Bug 39863

Author: jason
Date: Wed Oct  7 19:31:56 2009
New Revision: 152538

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152538
Log:
	PR c++/39863
	* pt.c (tsubst_pack_expansion): Don't do anything now if we
	have incomplete packs of different lengths.

	PR c++/41038
	* tree.c (build_qualified_name): Call convert_from_reference.

	* pt.c (register_specialization): Push DECL_SOURCE_LOCATION to the
	clones.

	* decl.c (grok_special_member_properties): Only adjust
	TYPE_HAS_COMPLEX_* if the function is defaulted in the class body.
	(cp_finish_decl): Push DECL_DELETED_FN/DECL_DEFAULTED_FN to the
	clones.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/defaulted13.C
      - copied unchanged from r152373, trunk/gcc/testsuite/g++.dg/cpp0x/defaulted13.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/variadic95.C
      - copied unchanged from r152537, trunk/gcc/testsuite/g++.dg/cpp0x/variadic95.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/scope3.C
      - copied unchanged from r152537, trunk/gcc/testsuite/g++.dg/template/scope3.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/decl.c
    branches/gcc-4_4-branch/gcc/cp/pt.c
    branches/gcc-4_4-branch/gcc/cp/tree.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 5 Jason Merrill 2009-10-07 19:32:40 UTC
Fixed for 4.4.2 and 4.5.