------- Comment #2 from baichangjun at gmail dot com 2009-05-17 23:08 -------
It is not expected. I have done some tests with gcc i386, x86_64, amd64 and
powerpc version. only i386 compiler replaces strlen by builtin function. the
other compilers gave a warning msg: "warning: conflicting types for built-in
function 'strlen'", and chose the correct strlen function in test.c.
test result in x86_64 system:
Target: x86_64-linux-gnu
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
$ cat test.c
int strlen(char *p)
{
return 0;
}
main()
{
return strlen(0);
}
$ gcc -S -O1 test.c
test.c:2: warning: conflicting types for built-in function 'strlen'
$ cat test.s
.file "test.c"
.text
.globl strlen
.type strlen, @function
strlen:
.LFB2:
movl $0, %eax
ret
.LFE2:
.size strlen, .-strlen
.globl main
.type main, @function
main:
.LFB3:
movl $0, %edi
call strlen
rep ; ret
.LFE3:
.size main, .-main
.......
.ident "GCC: (GNU) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)"
.section .note.GNU-stack,"",@progbits
$
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40179