[GCC 3.2] Unexpected warning 'strchr' defined but not used

Sam Ravnborg sam@ravnborg.org
Sat May 17 22:42:00 GMT 2003


On Sat, May 17, 2003 at 09:07:13PM +0100, Neil Booth wrote:
> > #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.
> 
> The kernel is a special case; GCC is entitled to assume the existence of
> standard C library functions.  You need to work around it, with
> -fno-builtin perhaps.

The workaround was simple.
strstr(NULL, "%") => strchr(NULL, '%')

But wanted to report it.

	Sam



More information about the Gcc-bugs mailing list