User account creation filtered due to spam.

Bug 48292 - [C++0x] "sorry, unimplemented: use of 'type_pack_expansion' in template"
Summary: [C++0x] "sorry, unimplemented: use of 'type_pack_expansion' in template"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
: 44167 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-03-25 23:51 UTC by Nathan Ridge
Modified: 2011-05-25 15:29 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-25 03:17:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge 2011-03-25 23:51:04 UTC
For the following code:

template <typename... Args> int g(Args...);

template <int N = 0>
struct A
{
    template <typename... Args>
    static auto f(Args... args) -> decltype(g(args...));
};

int main()
{
    A<>::f();
    return 0;
}

gcc gives the following errors:

test.cpp: In function 'int main()':
test.cpp:7:27: sorry, unimplemented: use of 'type_pack_expansion' in template
test.cpp:12:12: error: no matching function for call to 'A<>::f()'
test.cpp:12:12: note: candidate is:
test.cpp:7:55: note: template<class ... Args> static decltype (g(A::f::args ...)) A::f(Args ...) [with Args = {Args ...}, int N = 0, decltype (g(A::f::args ...)) = int]

Are there any plans to implement this?
Comment 1 Nathan Ridge 2011-03-25 23:52:22 UTC
Also, does someone know a workaround for this?
Comment 2 Nathan Ridge 2011-03-26 00:02:32 UTC
Found a workaround:

#include <type_traits>

template <typename... Args> 
int g(Args...);

template <typename... Args>
struct deduce
{
    typedef decltype(g(std::declval<Args>()...)) type;
};

template <int N = 0>
struct A
{
    template <typename... Args>
    static typename deduce<Args...>::type f(Args... args);
};

int main()
{
    A<>::f();
    return 0;
}
Comment 3 Paolo Carlini 2011-03-28 16:27:43 UTC
CC-ing Jason about this one too. By the way, isn't the first time this sorry message surfaces, eg, Comment #4 in PR44167.
Comment 4 Jonathan Wakely 2011-05-24 12:44:35 UTC
*** Bug 44167 has been marked as a duplicate of this bug. ***
Comment 5 Jonathan Wakely 2011-05-24 12:50:45 UTC
(In reply to comment #3)
> CC-ing Jason about this one too. By the way, isn't the first time this sorry
> message surfaces, eg, Comment #4 in PR44167.

... actually adding Jason to the CC list ;)

I've marked the other as a dup after comparing the results for both testcases
with G++ 4.4 and later versions.

Jason, is this likely to be easy to fix?  I've been hitting this and PR 47335
while implementing std::allocator_traits.  If they aren't likely to be fixed in
the near future I'll look into workarounds
Comment 6 Jonathan Wakely 2011-05-25 09:05:15 UTC
Jason, I've found a decent workaround now so if you have higher priority issues you'd rather fix then don't spend time on this one for my benefit. Thanks for the incredible number of fixes you're making at the moment!
Comment 7 Jason Merrill 2011-05-25 14:32:09 UTC
Author: jason
Date: Wed May 25 14:32:06 2011
New Revision: 174201

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174201
Log:
	PR c++/48292
	* pt.c (tsubst_decl) [PARM_DECL]: Handle partial instantiation of
	function parameter pack.
	(tsubst_pack_expansion): Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic109.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Jason Merrill 2011-05-25 15:26:18 UTC
Author: jason
Date: Wed May 25 15:26:14 2011
New Revision: 174207

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174207
Log:
	PR c++/48292
	* pt.c (tsubst_decl) [PARM_DECL]: Handle partial instantiation of
	function parameter pack.
	(tsubst_pack_expansion): Likewise.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/variadic109.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/pt.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 9 Jason Merrill 2011-05-25 15:29:42 UTC
Fixed for 4.6.1.