This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: what is wrong here?


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

> You seem to assume that a using-declaration makes the functions
> denoted members of the namespace.

Nope, I assume that, after a using-declaration, name lookup finds the
``used'' name in the namespace in which the using-declaration
appeared, and thus doesn't consider it `undeclared' in the friend
declaration.  Same for:

namespace A {
  class B {};
}
namespace C {
  using A::B; // arranges that C::B -> A::B
  class D {
    friend class B; // doesn't this find C::B, i.e., A::B ?
  };
}

> If that was the case, then you would get violations of the odr.

Nope, I'm not talking about definitions, only declarations.  WRT
definitions, see below.

> Otherwise, is the following text well-formed?

> namespace A{void foo(){}}
> namespace B{void foo(){}}
> namespace C{using A::foo;using B::foo;class Bar{friend void foo();};}

> My interpretation is: Yes, it is, but C::foo is not defined, yet.

IMHO, no, because of ambiguity.

>> I can't seem to find the restriction that a non-member function can
>> only be defined in enclosing namepaces in the Standard at this very
>> moment; am I mistaken?

> It is in 7.3.1.2, [namespace.memdef]/2. However, this rule does not
> strictly apply: the member is not defined by explicit qualification.

Yup, I had found that one, but indeed it didn't apply.  Now the issue
is which restriction is missing in the Standard.  If your
interpretation is right, it should be made clear that friend
declarations in class bodies do not accept names introduced with using
declarations when checking whether a function had already been
declared in the namespace or not.  If mine is, the Standard should be
ammended to make it clear that friend declarations may match previous
using-declarations in the enclosing namespace.

In any case, it should be made clear that a definition cannot be
provided for an unqualified name declared by a using declaration.

Could you and/or some Cygnus employee take this issue to the C++
committee?


Cheers,

-- 
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]