[GCC 3.2] Unexpected warning 'strchr' defined but not used
Sam Ravnborg
sam@ravnborg.org
Sat May 17 20:35:00 GMT 2003
gcc emits a warning about 'strchr' being defined but not used when
compiling the following piece of code in the linux kernel:
foo.c:
#include <linux/string.h>
void foo(void)
{
strstr(NULL, "%");
}
Inspecting the .lst file I could see that gcc recognises the
strstr with a one char string as second argument is better served with strchr.
Therefore the static extern inline version is included.
But gcc emits a warning that strchr is defined but never used in this case.
Use the following command to reproduce:
gcc -D__KERNEL__ -Iinclude -Wall -O2 -c foo.c
Executed in the top level directory of the linux kernel (2.5.69).
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
Sam
More information about the Gcc-bugs
mailing list