This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/40179] Incorrectly use Built-in function to replace the normal function with flag -O1
- From: "baichangjun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 May 2009 23:08:52 -0000
- Subject: [Bug c/40179] Incorrectly use Built-in function to replace the normal function with flag -O1
- References: <bug-40179-17725@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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