Bug#37295: -fno-inline causes strcpy(foo, "") to break
Package: libc6-dev
Version: 2.1.1-2
Consider the following program:
#include <string.h>
#include <stdio.h>
int main(void) {
char s[10];
strcpy(s, "");
printf("s=%s.\n", s);
return 0;
}
As far as I can determine, it is strictly conforming standard C. If I compile
it without -fno-inline, the following happens:
$ gcc -O foo.c
$ ./a.out
s=.
Ergo, it works as it should. If I use -fno-inline, however, it fails to work:
$ gcc -O -fno-inline foo.c
/tmp/cc49Syvn.o: In function `main':
/tmp/cc49Syvn.o(.text+0x91): undefined reference to `__strcpy_small'
collect2: ld returned 1 exit status
As far as I understand, I should be able to use -fno-inline. The problem,
I think, is due to how /usr/include/string.h and/or /usr/include/bits/string2.h
decide on whether to use a macro of strcpy that expands to a call to
__strcpy_small in some circumstances.
Reply to: