explicit member template arguments problem (gcc 2.95.2)

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Tue Apr 4 15:40:00 GMT 2000


> // - it seems to be a problem with calling a member template
> // defined in a template base class with explicit template
> // arguments

Thanks for your bug report. This is not a bug in the compiler, but a
bug in your code.

		f<int>();		// fail: parse error before '>'

If the base class name depends on a template parameter, names of base
classes are not found during parsing, but only at instantiation time.
Therefore, f is not a template, and 'f<int' is an expression. Thus, it
is a syntax error - you need to qualify f with the base class.

		B<T>::f<int>();		// fail: parse error before '>'

Here, you qualify correctly, but the parser still cannot determine
that f is a template - it depends on the value of T whether it
is. Instead, you have to write.

		B<T>::template f<int>();

If you question this analysis, please discuss it in one of the public
C++ fora first, eg. comp.lang.c++.moderated, or comp.std.c++.

Regards,
Martin


More information about the Gcc-bugs mailing list