From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 873 invoked by alias); 17 May 2009 17:38:39 -0000 Received: (qmail 834 invoked by uid 48); 17 May 2009 17:38:22 -0000 Date: Sun, 17 May 2009 17:38:00 -0000 Subject: [Bug c/40179] New: Incorrectly use Built-in function to replace the normal function with flag -O1 X-Bugzilla-Reason: CC Message-ID: 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/msg01465.txt.bz2 I implemented another 'strlen' function with the same name, I didn't include the 'stdio.h' file, but when I used -O1 flag, the function has been replaced by "repnz scasb" without warning. Test case is following: $ cat test.c int strlen(char* p) { return 0; } main() { return strlen(0); } $ gcc -S -O1 test.c $ cat test.s .file "test.c" .text .globl strlen .type strlen, @function strlen: pushl %ebp movl %esp, %ebp movl $0, %eax popl %ebp ret .size strlen, .-strlen .globl main .type main, @function main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) pushl %ebp movl %esp, %ebp subl $8, %esp movl %ecx, (%esp) movl %edi, 4(%esp) movl $0, %edi movl $0, %eax movl $-1, %ecx repnz scasb notl %ecx leal -1(%ecx), %eax movl (%esp), %ecx movl 4(%esp), %edi movl %ebp, %esp popl %ebp leal -4(%ecx), %esp ret .size main, .-main .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)" .section .note.GNU-stack,"",@progbits $ -- Summary: Incorrectly use Built-in function to replace the normal function with flag -O1 Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: baichangjun at gmail dot com GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40179