This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Builtins and C++ and such


Mark Mitchell <mark@codesourcery.com> writes:

| Worrying about the ODR is somewhat pedantic; we already probably
| violate the ODR in some ways, and that's no big deal as long as
| the definitions do close enough to the same thing.

I'm not sure how GCC currently behaves in face of the following:

   // system C-header string.h
 
   static inline void* 
   memcpy(...) { }

   // V3 header cstring
   extern "C" {
   #include </system/string.h> // or equivalent
   }
   namespace std
   {
      extern "C"
      inline void*
      memcpy(...) { return ::memcpy(...); }
   }
   
which is a manifest violation of ODR normally triggering a due error.

| But, I think your key point (std::memcpy and ::memcpy should have
| the same address) is good.  Does the standard actually talk about
| ::memcpy somewhere and say this, or are we just inferring it? 

Yes, it does:
D.5/2
  Each C header, whose name has the form name.h, behaves as if each
  name placed in the Standard library namespace by the corresponding
  cname header is also placed within the namespace scope of the
  name-space std and is followed by an explicit using-declaration (7.3.3)

which unambigously implies that ::memcpy and std::memcpy designates the
same function.

-- Gaby


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