g++ 2.95.2 can't handle dependent friend member functions

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sun Mar 5 04:08:00 GMT 2000


> the program below doesn't compile with g++ 2.95.2. I can't find anything
> in 11.4 or in 14.5.3 that would indicate that the code is not legal. It
> compiles fine with edg 2.42. Am I missing something or is this a g++
> bug?

I'm not sure. In 8/4, a declarator is defined as (among other options)

  direct­declarator:
             declarator­id
             ...

  declarator­id:
             id­expression
             ...

In 5.1, this is defined  as

  id­expression:
             unqualified­id 
             qualified­id

  qualified­id:
             ::opt nested­name­specifier template-opt unqualified­id

  nested­name­specifier:
             class­or­namespace­name :: nested­name­specifier-opt 
             class­or­namespace­name :: template nested­name­specifier

  class­or­namespace­name:
             class­name
             namespace­name

So in a qualified id, you can only use class-names and
namespace-names. 14.1/3 says a type-parameter is a type-name; it does
not say it is a class-name. As a result, you cannot qualify a friend
with a template type parameter. This is consistent with the
restriction that you cannot declare a template parameter as a friend
(7.1.5.3/2)

Now, of course, following this interpretation has some interesting
consequences, so I suspect a Defect somewhere.

Regards,
Martin


More information about the Gcc-bugs mailing list