Bug 25731

Summary: strcpy breaks with -O2 -fno-inline
Product: [Retired] Red Hat Linux Reporter: Stefan Sorensen <sts>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-02-02 16:43:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stefan Sorensen 2001-02-02 16:43:51 UTC
$ cat foo.c
#include <string.h>
int main(void)
{
    char foo[4];
    strcpy(foo, "foo");
    return 0;
}

$ gcc -O2 -fno-inline foo.c
/tmp/ccLwrlUH.o: In function `main':
/tmp/ccLwrlUH.o(.text+0x5c): undefined reference to `__strcpy_small'
collect2: ld returned 1 exit status

$ rpm -q glibc gcc
glibc-2.2.1-3
gcc-2.96-71

Comment 1 Jakub Jelinek 2001-02-02 16:53:50 UTC
Pass -O2 -fno-inline -D__NO_STRING_INLINES then. Really, there is nothing
glibc can do about this (apart from exporting all those inlines as static
functions but that makes no sense) and gcc does not pass any macros
which would tell whether -finline or -fno-inline was passed, so it has to use
__OPTIMIZE__ (and has done that for ages).