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:

[...]

| The bottom line is that I'd still really rather see this fixed in
| the headers (where it's easy to do:
| 
|   extern "C" inline memcpy() { __builtin_memcpy(); }
| 
| ) that have special gunk in the compiler.

That cannot be done for targets the C-headers of whose we don't have
control on -- that is, currently, virtually all targets -- because
either we would violate the ODR or failed to satisty the requirement
&std::memcpy == &::memcpy.  In the past, it has been suggested that
Glibc could do that parts of the work for us, but that doesn't solve
the problem for the rest of the targets.

I'm strongly of the opinion of Jason that, even thought the ideal
would be to have the library do most of the dirty work, the compiler
ought to assist us through some extensions.

Here is a fourth suggestion.
Suppose for a moment that the compiler is smart enought (or can be
made smart) to replace a reference to a function by the
referenced function where possible, then we could say:

   void(&memcpy)(void*, const void*, size_t) = __builtin_memcpy;

That would preserve the identity of addresses, and if the compiler
does function reference-folding (something I expect it should do) then
we won't loose efficiency.  It would remain the issue of name-lookup.
The compiler could be extended to apply Koenig lookup (where
applicable) to reference-to-function -- and actually, the issue of
extending Koenig lookup to function object is seriously taken by
several committee members.

The above suggestion also alleviates the needs of writting ten
thousands of overloads which all have syntactically the same body.

-- Gaby


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