http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53837

             Bug #: 53837
           Summary: Unpacking variadic template parameters in a method
                    parameter default value gives parse error
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: johan...@laire.fi


-------- bug.cpp --------
template <typename... Args>
int f() { return 42; }

template <typename... Args>
struct B1 {
        B1(int i = f<Args...>()); // ERROR
        void m(int i = f<Args...>()); // ERROR
};

struct B2 {
        template <typename... Args>
        void m(int i = f<Args...>()); // ERROR
};

template <typename... Args>
struct B3 {
        B3(int i = call_f()); // OK
        void m(int i = call_f()); // OK
        static int call_f() { return f<Args...>(); }
};

template <typename... Args>
void g(int i = f<Args...>()); // OK

int main() {}
-------- bug.cpp --------

$ g++ -std=c++0x bug.cpp
bug.cpp:6:22: error: expected ‘)’ before ‘>’ token
bug.cpp:6:19: error: expected ‘;’ at end of member declaration
bug.cpp:6:22: error: expected unqualified-id before ‘>’ token
bug.cpp:7:26: error: expected ‘)’ before ‘>’ token
bug.cpp:7:23: error: expected ‘;’ at end of member declaration
bug.cpp:7:26: error: expected unqualified-id before ‘>’ token
bug.cpp:6:13: error: parse error in template argument list
bug.cpp:7:17: error: parse error in template argument list
bug.cpp:12:26: error: expected ‘)’ before ‘>’ token
bug.cpp:12:26: error: expected initializer before ‘>’ token
$ clang++ -std=c++0x bug.cpp
$


GCC versions 4.4.3, 4.6.2, and 4.7.1 give parse errors on the marked lines.
Clang 3.0 doesn't complain.

Note that g() parses fine.

Reply via email to