Builtins and C++ and such
Gabriel Dos Reis
gdr@codesourcery.com
Thu Mar 21 00:19:00 GMT 2002
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
More information about the Gcc
mailing list