g++ 2.95.2 parse error taking address of a template function
llewelly@dbritsch.dsl.xmission.com
llewelly@dbritsch.dsl.xmission.com
Tue Apr 25 23:52:00 GMT 2000
On Tue, 25 Apr 2000, Martin Sebor wrote:
[snip]
> >
> > 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
>
No, I cannot. I should not have spoken before looking at the standard,
sorry.
# 14.6.4 Dependent name resolution
# In resolving dependent names, names from the following sources are
# considered:
#
# - Declaratinos that are visible at the point of definition of the
# template.
#
# - Declarations from namespaces associated with the types of the function
# arguments both from the instantiation context (14.6.4.1) and from the
# definition context.
Seems to support your position as well. At the very least it seems
relevant.
I looked at 14.6.4.2, but bar<T> looks like a template id to me, so it
didn't seem relevant.
I tried to find a general rule that
Note that gcc will also reject a template dependent function call, if the
function is not declared before the template definition. If you are
correct (and now I think you are), this is also a bug, or an aspect of
the same bug.
{~/cc_exer}g++ -g -Wall call_template_func.cc
call_template_func.cc: In function `void foo()':
call_template_func.cc:4: parse error before `>'
{~/cc_exer}cat call_template_func.cc
template <class T>
void foo()
{
bar<T> ();
}
template <class T>
void bar () { }
int main()
{
foo<int> ();
}
{~/cc_exer}g++ --version
2.95.2
More information about the Gcc-bugs
mailing list