Compiling the code // start tmp.cpp template<class T,class S> struct A{}; struct B { void f(A<int,int> default_value=A<int,int>()); }; // end tmp.cpp with g++ tmp.cpp produces these errors tmp.cpp:6: error: expected ‘,’ or ‘...’ before ‘>’ token tmp.cpp:6: error: missing ‘>’ to terminate the template argument list tmp.cpp:6: error: wrong number of template arguments (1, should be 2) tmp.cpp:2: error: provided for ‘template<class T, class S> struct A’ tmp.cpp:6: error: expected ‘,’ before ‘int’ The errors disappear if 1. The function is moved outside of the second struct definition. 2. The second template argument to A is removed. 3. The default argument is removed. 4. A typedef is used to encapsulate A<int,int>. 5. Comeau 4.3.3 is used.
This is a dup of bug 57 and in fact an issue with the standard as this is Defect report 325 for the C++ standard. According to the current standard as written, GCC is correct to reject this code. *** This bug has been marked as a duplicate of 57 ***