public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40179]  New: Incorrectly use Built-in function to replace the normal function with flag -O1
@ 2009-05-17 17:38 baichangjun at gmail dot com
  2009-05-17 19:10 ` [Bug c/40179] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: baichangjun at gmail dot com @ 2009-05-17 17:38 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-05-18  0:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-17 17:38 [Bug c/40179] New: Incorrectly use Built-in function to replace the normal function with flag -O1 baichangjun at gmail dot com
2009-05-17 19:10 ` [Bug c/40179] " pinskia at gcc dot gnu dot org
2009-05-17 23:09 ` baichangjun at gmail dot com
2009-05-18  0:37 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).