From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6674 invoked by alias); 17 May 2009 23:09:06 -0000 Received: (qmail 6657 invoked by uid 48); 17 May 2009 23:08:52 -0000 Date: Sun, 17 May 2009 23:09:00 -0000 Message-ID: <20090517230852.6656.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/40179] Incorrectly use Built-in function to replace the normal function with flag -O1 In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "baichangjun at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg01482.txt.bz2 ------- 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