This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Internal compiler error on template of template
- To: Guillaume Laurent <glaurent at worldnet dot fr>
- Subject: Re: Internal compiler error on template of template
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 07 Jun 1998 16:48:14 -0300
- Cc: egcs-bugs at cygnus dot com
- References: <m3yav9wp7b.fsf@linux2.worldnet.fr>
Guillaume Laurent <glaurent@worldnet.fr> writes:
> The following code produces an internal compiler error with egcs 1.0.3:
I was unable to reproduce the ICE with egcs 1.0.3 on
sparc-sun-solaris2.5; instead I got:
test2.cc:9: sorry, not implemented: `field_decl' not supported by dump_type
test2.cc: In function `void tfunc2<R>(class Foo *, void *)':
test2.cc:9: conversion from `void *' to non-scalar type `' requested
Nevertheless, it seems to me that your template function declaration
is not correct:
> template <class T>
> template <class R>
> void tfunc2(T* objptr, void *_methodptr)
This kind of syntax is used to define template member-functions of
template classes, like this:
template <class T> class foo { template <class T2> void bar(); };
template <class T> template <class T2> void foo<T>::bar<T2>() {}
However, I'm not sure the syntax is invalid. Anyway, I'd recomment
you to use the notation:
template <class R, class T>
because the template argument R cannot be deduced, so you'll have to
specify it whenever you call tfunc2:
> void meta_tfunc(Foo *f, int (Foo::*m_ptr)(void))
> {
> tfunc2(f, (void*)0);
tfunc2<int>(f, (void*)0);
Furthermore, in tfunc2, you try to cast `void*' to a pointer to
member, but this is impossible. In C++, one cannot convert pointers
to non-members to pointers to members, nor the converse.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil