g++ 2.95.2 parse error taking address of a template function
Martin Sebor
sebor@roguewave.com
Tue Apr 25 21:08:00 GMT 2000
llewelly@dbritsch.dsl.xmission.com wrote:
>
> On Thu, 20 Apr 2000, Martin Sebor wrote:
>
> > Hi,
> >
> > g++ 2.95.2 gives a parse error when taking the address of a template
> > function.
> >
> > Thanks
> > Martin
> >
> >
> > $ cat test.cpp
> >
> > template <class T>
> > void foo ()
> > {
> > void (*pf)() = &bar<T>;
> > }
> >
> > template <class T>
> > void bar () { }
> >
> >
>
> I think the template func needs to be declared before its first use.
I'm having trouble finding the sentence in the standard that requires it -
14.6., p8 says that " The lookup of names dependent on the template parameters
is postponed until the actual template argument is known..." Can you point to a
section/paragraph that excludes the address-of operator expression from the
rule above?
Thanks
Martin
>
> {~/cc_exer}cat address_of_template_func.cc
> template <class T>
> void bar () ;
>
> template <class T>
> void foo ()
> {
> void (*pf)() = &bar<T>;
> }
>
> template <class T>
> void bar () { }
>
> compiles fine with gcc 2.95.2
>
> [snip]
More information about the Gcc-bugs
mailing list