A
absurd
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 functioncall to memcpy is in the executable (with objdump). With optimization, thememcpy 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 inthe standard library ?
Thanks.
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 functioncall to memcpy is in the executable (with objdump). With optimization, thememcpy 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 inthe standard library ?
Thanks.