Hi, // Bug: default Parameter with a template-Type does not work with more than 1 template parameter #include <stdio.h> template <typename _type> class A { _type local; public: A(_type val) { local=val; printf("A\n"); } }; template <typename _type, typename _type1> class B { _type local; public: B(_type val) { local=val; printf("B\n"); } }; template<typename _type, typename _type1> class C { public: C() { printf("C\n"); } void proc1(A<_type> par = A<_type>(42)) {}; // works // doesnt't work --> compile error #ifdef CASE1 void proc2(B<_type, _type1> par = B<_type, _type1>(42)) {}; #endif // works #ifdef CASE2 typedef B<_type, _type1> yyy; void proc2(B<_type, _type1> par = yyy(42)) {}; #endif }; main() { C<int, int> c; c.proc1(); c.proc2(); } results in compiler output: CASE1: arzt@dbnu003{~/g++} /opt/gcc-3.4/bin/g++ -DCASE1 test1.cpp test1.cpp:25: error: expected `,' or `...' before '>' token test1.cpp:25: error: missing `>' to terminate the template argument list test1.cpp:25: error: wrong number of template arguments (1, should be 2) test1.cpp:12: error: provided for `template<class _type, class _type1> class B' test1.cpp: In function `int main()': test1.cpp:38: error: no matching function for call to `C<int, int>::proc2()' test1.cpp:25: note: candidates are: void C<_type, _type1>::proc2(B<_type, _type1>, _type1) [with _type = int, _type1 = int] CASE2: arzt@dbnu003{~/g++} /opt/gcc-3.4/bin/g++ -DCASE2 test1.cpp arzt@dbnu003{~/g++} ./a.out C A B I think both codes sequences are correct and should behave identical. Same Problem with g++ 3.3.3. The following compilers work correctly: SunWorkshop 8, HP Tru64 CXX 6.5, MS Visual C++ 6.0 SP5 Thanks Uwe
Created attachment 6186 [details] Testprogram
Created attachment 6187 [details] Output with g++ -v
This is a duplicate of one of our very (very very) old bug reports, PR 57. W. *** This bug has been marked as a duplicate of 57 ***