This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

g++ Template call through pointer - a bug?


Hi,

Here is a short program that fail to compile with single error that I can not
explain. Here I try to call a member function template via pointer to object.
Seemingly the same code compiles in one context and fails in other with syntax
error. I would not claim this is a bug, but it does look like one to me. What
am I missing here? gcc version 3.3.3 (mingw special)

Thanks
Vladimir

-------------------------
#include <stdio.h>
struct A {
	template <class T> void fun() {
		printf("%d\n",sizeof(T));
	}
};

struct B {
	A *a;
	B(A *ia) {
		a = ia;
	}
	template <class T> void fun() {
		a->fun<T>(); // This works
	}
};

template <class T> void ptrfun(A* a) {
	a->fun<T>(); // tst.cpp:19: error: syntax error before `>' token
}

int main() {
	A a;
	B b(&a);

	a.fun<int>();
	b.fun<double>();
	ptrfun<char>(&a);	
}
-------------------------------------------


		
__________________________________ 
Yahoo! Messenger 
Show us what our next emoticon should look like. Join the fun. 
http://www.advision.webevents.yahoo.com/emoticontest


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]