http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888

--- Comment #12 from Brooks Moses <brooks at gcc dot gnu.org> ---
(In reply to Paulo J. Matos from comment #11)
> A non-bug? If you write a memcpy function by hand and call it memcpy, gcc
> replaces the function body by a call to memcpy which generates an infinite
> loop. How come it's a non-bug?

Because if you do that you're invoking undefined behavior.  There's already a
memcpy function in the standard library, so naming your own function memcpy
violates the one-definition-per-function rule.  Even if it "worked", naming
your own function memcpy would likely break other standard library functions
that call the "real" memcpy.

Now, if this replacement still happens when you compile with -nostdlib, that
would be a bug since it becomes legal code in that case.  But that's somewhat
of a separate issue and should be filed separately if it happens.  (We should
arguably also have a test for it, if we don't already.)

Reply via email to