can't take address of static template member funcion?

Niall Smart njs3@doc.ic.ac.uk
Sun May 24 04:40:00 GMT 1998


On May 23,  5:47pm, Corey Kosak wrote:
} Subject: can't take address of static template member funcion?
> 
> I *think* this is legal C++, but neither egcs 1.0.3 nor gcc 2.8.1 appear to
> like it.
>
> > g++ --version bug.cc ; g++ bug.cc || cat bug.cc
> egcs-2.90.29 980515 (egcs-1.0.3 release)
> bug.cc:14: sorry, not implemented: `template_id_expr' not supported by dump_decl
> bug.cc: In function `int main()':
> bug.cc:14: `class cow' has no member named `'
> #include <stdio.h>
> 
> class cow {
> public:
>   template <class T>
>   static void func() {
>     printf("hi!\n");
>   }
> };
> 
> int main()
> {
>   cow().template func<int>();             // OK
>   void (*fp)()=&cow().template func<int>; // error
>   return 0;
> }

I think this should be:

void (*fp)() = &cow::template func<int>;

I submitted a very similar bug report yesterday.

I'm surprised that the first line compiles, I would have though it
should be:

	cow::template func<int>();

Is the syntax documented as valid?

Niall



More information about the Gcc-bugs mailing list