This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53837] New: Unpacking variadic template parameters in a method parameter default value gives parse error


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: unassigned@gcc.gnu.org
        ReportedBy: johannes@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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]