Yet another template bug in gcc-2.95.1

Alexandre Oliva oliva@dcc.unicamp.br
Tue Aug 31 12:46:00 GMT 1999


On Aug 30, 1999, "Martin v. Loewis" <martin@mira.isdn.cs.tu-berlin.de> wrote:

>> I read the code as declaring a particular specialization of the
>> template function as a friend.

> What about 3.3.6, [basic.scope.class]/1?

> # A name N used in a class S shall refer to the same declaration in
> # its context and when re­evaluated in the completed scope of S. No
> # diagnostic is required for a violation of this rule.

> In its context, the name in the template-id certainly refers to the
> template.

Thus, it introduces the name into the class scope, and, later on, it
is overloaded with the member function.  I don't think they should
conflict.

>> Yup, but, as you probably already know, this is much more permissive,
>> since it grants privileged access to *all* specializations of the
>> template function.

> Indeed. However, if you declare a specialization as the friend, there
> is also a need to define the specialization, provided the
> specialization is used, right? (14.7.3/6)

Nope, you only have to provide a separate definition when a
specialization is declared, which means it must start with `template
<...>', and be in namespace scope.  In the case of the friend
declaration, it's just referring to a particular specialization, like
explicitly specifying template members when doing a template function
call.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


More information about the Gcc-bugs mailing list