Bug 38543 - [C++0x] Cannot specialize variadic template function
Summary: [C++0x] Cannot specialize variadic template function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.2
: P3 normal
Target Milestone: 4.7.1
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
: 53723 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-12-16 21:39 UTC by Ji Chao Zhang
Modified: 2012-06-20 13:01 UTC (History)
4 users (show)

See Also:
Host: powerpc64-suse-linux
Target:
Build:
Known to work:
Known to fail: 4.4.0, 4.7.0
Last reconfirmed: 2012-01-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ji Chao Zhang 2008-12-16 21:39:50 UTC
GCC 4.3.2 failed to compile code with vairadic template function specialization.

Here is the code causing the problem:

template< typename ... T > void foo( T ... args );
template<> void foo( int, double ){}
int main()
{
  foo( 0, 0.0 );
  return 55;
}

I got the following error msg:
test.cpp:3: error: template-id 'foo<>' for 'void foo(int, double)' does not match any template declaration

However, the specialization using only one parameter can pass:

template< typename ... T > void foo( T ... args );
template<> void foo( int ){}
int main()
{
  foo( 0 );
  return 55;
}

Command used to compile:

g++ -std=c++0x    test.cpp   -o test

Output from -v:

Using built-in specs.
Target: powerpc64-suse-linux
Configured with: ../configure --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3 --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.3 --enable-version-specific-runtime-libs --enable-linux-futex --without-system-libunwind --with-cpu=power4 --enable-secureplt --with-long-double-128 --build=powerpc64-suse-linux
Thread model: posix
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
Comment 1 Andrew Pinski 2012-01-28 06:29:31 UTC
Confirmed.
Comment 2 Jason Merrill 2012-04-17 02:29:54 UTC
Author: jason
Date: Tue Apr 17 02:29:51 2012
New Revision: 186522

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186522
Log:
	PR c++/38543
	* pt.c (determine_specialization): Instead of comparing the number
	of parms, check that tsubst gives the right answer.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic131.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2012-04-17 03:34:04 UTC
Fixed for 4.8.
Comment 4 Jason Merrill 2012-04-17 14:11:43 UTC
Author: jason
Date: Tue Apr 17 14:11:34 2012
New Revision: 186533

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186533
Log:
	PR c++/38543
	* pt.c (determine_specialization): Instead of comparing the number
	of parms, check that tsubst gives the right answer.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/variadic131.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/pt.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 5 Jason Merrill 2012-04-17 15:28:55 UTC
Also fixed for 4.7.1.
Comment 6 Jonathan Wakely 2012-06-20 13:01:09 UTC
*** Bug 53723 has been marked as a duplicate of this bug. ***