Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how does gcc inline the 'memcpy'

1,193 views
Skip to first unread message

absurd

unread,
Jul 12, 2012, 11:27:28 AM7/12/12
to
Hello,

I have the following simple code.

#include <string.h>

int main()
{
char dst[50];
char src[50];
memcpy(dst, src, 50);
return dst[1];
}

When I use gcc to compile it without any optimization, I can see a function call to memcpy is in the executable (with objdump). With optimization, the memcpy seems to be inlined.

I checked string.h. It has only the declaration of memcpy, not implementation. The implementation is in glibc. My understanding is in order to inline, gcc has to see the function implementation when it compiles. How does the gcc inline memcpy here ? Does it have special treatment to the functions in the standard library ?

Thanks.




}

Andrew Haley

unread,
Jul 13, 2012, 5:31:47 AM7/13/12
to
Yes, it does. GCC has lots of builtin functions. You can turn them
off with -fno-builtin .

Andrew.
0 new messages