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