[Bug c++/18950] New: specialization of template class with inner template members
The following code used to compile fine with gcc 3.3 (linux x86), but doesn't anymore with gcc 3.4 (just as a hint, it seems to compile fine with Comeau) : template class Class { public: template T2 function( T2 param ); }; template<> template T2 Class::function( T2 param ) { // line 11 return param * N2; } int main() { Class instance; return instance.function( 12 ); } This produces the following output: test-gcc34.cpp:11: error: template-id `function<>' for `T2 Class::function(T2)' does not match any template declaration test-gcc34.cpp:11: error: erreur de syntaxe before `{' token It works if we add the specialized declaration of the class "Class": template<> class Class { public: template T2 function( T2 param ); }; but this can be painful if "Class" contains a lot more members. It also works if "function" is only templated by one argument : template<> template T2 Class::function( T2 param ) { // line 11 return param * 2; } Thanks. -- Summary: specialization of template class with inner template members Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: boris at buf dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18950
[Bug c++/18950] specialization of template class with inner template members
--- Additional Comments From boris at buf dot com 2004-12-13 17:36 --- (In reply to comment #2) > 3.3.2 also rejects this code also: I'm really sorry, it seems I oversimplified our real test case (the previous problem might be related, but indeed it's not a regression). The following code is a closer version of what we have, and this time it compiles fine with g++ 3.3.1, but not with g++ 3.4.0 : template class Class { public: template void function( const Class& ); }; template<> template void Class::function( const Class& param ) { param;// line 12 } int main() { Class instance; Class param; instance.function( param ); } The output is : test-gcc34.cpp: In member function `void Class::function(const Class&) [with T2 = T2, int N2 = N2, T1 = int, int N1 = 1]': test-gcc34.cpp:12: error: `param' undeclared (first use this function) test-gcc34.cpp:12: error: (Each undeclared identifier is reported only once for each function it appears in.) Sorry about the misinformation in the first place. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18950