The following code used to compile under RH6.2 and still compiles with egcs++ (from compat-egcs-c++-6.2-1.1.2.9) under RH7.0. It does not compile under RH7.0 with g++ 2.96. The errors are reported below the sample code. #ifndef _TGRID_CC #define _TGRID_CC #include <fstream.h> #include <stdlib.h> template <class TYPE> class TGRID { public: int rows, cols; TGRID(int R=0, int C=0); ~TGRID(); template<class TYPE> friend ostream & operator<<(ostream & OUT, TGRID<TYPE> & G); template<class TYPE> friend istream & operator>>(istream & IN, TGRID<TYPE> & G); }; template <class TYPE> TGRID<TYPE>::TGRID(int R, int C) : rows(R), cols(C) { } template <class TYPE> TGRID<TYPE>::~TGRID() { } template <class TYPE> ostream & operator<<(ostream & OUT, TGRID<TYPE> & G) { return OUT; } template <class TYPE> istream & operator>>(istream & OUT, TGRID<TYPE> & G) { return IN; } #endif 479) silviu:~/TESTg++> g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.0) 480) silviu:~/TESTg++> g++ -c tgrid.cc tgrid.cc:17: declaration of `class TYPE' tgrid.cc:8: shadows template parm `class TYPE' tgrid.cc:20: declaration of `class TYPE' tgrid.cc:8: shadows template parm `class TYPE' I understand there is a chance that my code does not comply with the C++ standard, while gcc and g++ try to adhere to it, but in this case some warnings and some documentation about the new standard would have helped. The only docs with g++-2.96 are /usr/share/doc/gcc-c++-2.96/ChangeLog* Silviu Minut
C++ standard sais: A template-parameter shall not be redeclared within its scope (including nested scopes). So your testcase is wrong, just fix it up and be done with it. g++ 2.96 we ship is very close to the upcoming g++ 3 API, so you'd have to change your code anyway. As for documentation, there were really too many changes in the C++ frontend to document them all, the best documentation are C++ and C standards.