Bug 35297 - Compiling error with variadic template with fixed parameter with default type.
Summary: Compiling error with variadic template with fixed parameter with default type.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-02-22 17:40 UTC by Rodolfo Schulz de Lima
Modified: 2009-01-07 20:56 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.4.0
Last reconfirmed: 2009-01-06 16:17:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rodolfo Schulz de Lima 2008-02-22 17:40:50 UTC
Hi,
the following code fails to compile with gcc-4.3-20080215

template <class T=int, class... ARGS> 
struct test {};

int main()
{
        test<> a;
        return 0;
}

According to N2242 section 3.6, page 7:

If a template-parameter of a class template has a default template-argument, each subsequent template-parameter shall either have a default template-argument supplied or be a template parameter pack. If a template-parameter of a class template is a template parameter pack, it must be the last template-parameter. 

The compiler issues the following error: no default argument for ‘ARGS’  at line 1 above.
Comment 1 Andrew Pinski 2008-12-29 06:44:53 UTC
Confirmed.
Comment 2 Jason Merrill 2009-01-07 20:43:31 UTC
Subject: Bug 35297

Author: jason
Date: Wed Jan  7 20:43:01 2009
New Revision: 143166

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143166
Log:
        PR c++/35297
        PR c++/35477
        PR c++/35784
        PR c++/36846
        PR c++/38276
        * pt.c (check_default_tmpl_args): Don't complain about
        out-of-order parameter packs in the enclosing class
        or parameter packs after default args.
        (coerce_template_parms): If we have more than one
        parameter pack, don't flatten argument packs.
        (template_args_equal): Handle argument packs.
        (comp_template_args): Don't flatten argument packs.
        (check_instantiated_arg): Split out from...
        (check_instantiated_args): Here.  Handle arg packs.
        (convert_template_argument): Just check that nontype argument
        packs have the right type.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic92.C
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic93.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic65.C
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic82.C
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic83.C

Comment 3 Jason Merrill 2009-01-07 20:56:24 UTC
Fixed.