#include <utility> template < typename T > struct X { }; struct A { void f( X< std::pair< int, int > > v = X< std::pair< int, int > >() ); }; $ g++ tmp.cpp -Wall -c tmp.cpp:5: error: expected ‘,’ or ‘...’ before ‘>’ token tmp.cpp:5: error: wrong number of template arguments (1, should be 2) /usr/include/c++/4.1.2/bits/stl_pair.h:68: error: provided for ‘template<class _T1, class _T2> struct std::pair’ tmp.cpp:5: error: template argument 1 is invalid tmp.cpp:5: error: default argument missing for parameter 2 of ‘void A::f(X<std::pair<int, int> >, int)’ online comeau compiler accepts this testcase.
reduced testcase: template < typename T > struct X { }; template < typename T, typename U > struct Y { }; struct A { void f( X< Y< int, int > > v = X< Y< int, int > >() ); }; tmp.cpp:5: error: expected ‘,’ or ‘...’ before ‘>’ token tmp.cpp:5: error: wrong number of template arguments (1, should be 2) tmp.cpp:2: error: provided for ‘template<class T, class U> struct Y’ tmp.cpp:5: error: template argument 1 is invalid tmp.cpp:5: error: default argument missing for parameter 2 of ‘void A::f(X<Y<int, int> >, int)’
There is a Defect report about the comma in default arguments.
In fact this is a dup of bug 57 which is still SUSPENDED because the defect report has not been resolved yet. *** This bug has been marked as a duplicate of 57 ***