gcc builtin functions, e.g. memcpy, and namespace std

Nathan Myers ncm@cantrip.org
Fri May 19 01:15:00 GMT 2000


On Fri, May 19, 2000 at 08:41:05AM +0200, Martin v. Loewis wrote:
> > Regardless, the standard requires declared names in different 
> > namespaces to be considered different for purposes of name lookup
> > even if they would collide at link time.
> 
> No, it doesn't. 7.5/6 says
> 
> # At most one function with a particular name can have C language
> # linkage. Two declarations for a function with C language linkage
> # with the same function name (ignoring the namespace names that
> # qualify it) that appear in different namespace scopes refer to the
> # same function. Two declarations for an object with C lan­guage
> # linkage with the same name (ignoring the namespace names that
> # qualify it) that appear in different namespace scopes refer to the
> # same object.

My memory of the standard text is corroding.  I'd better cite chapter 
and verse for my recollections about core language semantics from 
now on.

I suspect what I meant to recall was that extern "C" names declared in
namespaces must be found in a namespace where they are declared, e.g.

  namespace A { extern "C" void f(); }
  namespace A { void g() { f(); }  // ok
  namespace B { void g() { A::f(); } // ok
  namespace B { void h() { f(); }  // error
  int main() { f(); }  // error

Apologies for the confusion.  Shall I plead lack of sleep, or old age?

Nathan Myers
ncm at cantrip dot org


More information about the Libstdc++ mailing list