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

             Bug #: 54377
           Summary: Consider default arguments in "wrong number of
                    template arguments" diagnostic
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: zeratul...@hotmail.com


Consider the following (invalid) code:


template <typename, typename, typename = void, typename = void>
struct foo {};

int main()
{
    foo<int> f;
}


The error message GCC gives is:


test.cpp: In function 'int main()':
test.cpp:6:12: error: wrong number of template arguments (1, should be 4)
     foo<int> f;
            ^
test.cpp:2:8: error: provided for 'template<class, class, class, class> struct
foo'
 struct foo {};
        ^


I think the "1, should be 4" part is misleading, since 2 or 3 template
arguments would also be valid.

I think the error message should be changed to:


test.cpp: In function 'int main()':
test.cpp:6:12: error: wrong number of template arguments (1, should be 2 to 4)
     foo<int> f;
            ^
test.cpp:2:8: error: provided for 'template<class, class, class, class> struct
foo'
 struct foo {};
        ^

Reply via email to