g++ bug or just bad code?

Rennie deGraaf degraaf@cpsc.ucalgary.ca
Thu Oct 23 21:32:00 GMT 2003


The attached code compiles and works properly when I comment out the 
declaration, definition, and invocations  of the method 'eck'. With 
"eck" in there, g++ fails with

ttest.cpp:23: template-id `eck<>' for `void blah<int>::eck(int)'
does not match any template declaration
ttest.cpp:23: syntax error before `{' token
ttest.cpp:25: syntax error before `<<' token

Note that 'gak' (a template function in a template class) works, as does
'ugh" (a normal function in a specialized template class); it's only
'eck', a template function in a specialized template class, that fails.

The compiler was g++ 3.2.2 20030222 on Red Hat 9 i386.

g++ 2.95.3 on Solaris SPARC 8 failed, with a different error.

It did compile on Solaris 8 using Sun's C++ compiler, but when I called 
blah<char> b.eck<float>() without ever defining a specialization for 
blah<char>::eck(), it just called blah<int>::eck().  This doesn't help 
me much, since the code must run on Linux i386.

Unfortunately, I don't have access to a system with a latest-release gcc 
to test.

Do I have a gcc bug, or just bad code?

If it is a bug, does anyone know of a workaround I could use for the 
time being?  If it's bad code, then what am I doing wrong?  Is Sun's CC 
in error compiling this?

Thanks for the help.


Rennie deGraaf

-- 
-ASCII silly question, get a silly ANSI.
                                 -????
			
			
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ttest.cpp
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20031023/34ec5979/attachment.ksh>


More information about the Gcc mailing list