Hi,
I think I'm seeing a bug with gcc which came in between 4.1.1 and 4.2.
I've got a function which takes a const void * and casts it to a void *
when passing it to another function. ONLY if the target function is in
the same module, I get the subject warning. A simple extern declaration
does not produce any warnings. Also, I see it at >= O3 or Os. This
does not show up at O2.
You will notice that without the explicit cast, I get the warning
TWICE. Thanks for any advice.
cat slab.c
void __cache_free(void *objp) { return; }
void kfree(const void *objp) { __cache_free((void *)objp); }
/* No warning @ O2 */
/m/btools/futures/next/builds/wip-4327-rt47353/ix86-Linux-RHEL4/i686-pc-linux-gnu_gcc-4.2.3/bin/gcc
-c -O2 -Wall slab.c
/* One warning @ O3 */
/m/btools/futures/next/builds/wip-4327-rt47353/ix86-Linux-RHEL4/i686-pc-linux-gnu_gcc-4.2.3/bin/gcc
-c -O3 -Wall slab.c
slab.c: In function 'kfree':
slab.c:2: warning: passing argument 1 of '__cache_free' discards
qualifiers from pointer target type
/* Now removing the explicit cast when calling __cache_free() */
/m/btools/futures/next/builds/wip-4327-rt47353/ix86-Linux-RHEL4/i686-pc-linux-gnu_gcc-4.2.3/bin/gcc
-c -O2 -Wall slab.c
slab.c: In function 'kfree':
slab.c:2: warning: passing argument 1 of '__cache_free' discards
qualifiers from pointer target type
/* and get the warning TWICE at O3 */
/m/btools/futures/next/builds/wip-4327-rt47353/ix86-Linux-RHEL4/i686-pc-linux-gnu_gcc-4.2.3/bin/gcc
-c -O3 -Wall slab.c
slab.c: In function 'kfree':
slab.c:2: warning: passing argument 1 of '__cache_free' discards
qualifiers from pointer target type
slab.c:2: warning: passing argument 1 of '__cache_free' discards
qualifiers from pointer target type
/m/btools/futures/next/builds/wip-4327-rt47353/ix86-Linux-RHEL4/i686-pc-linux-gnu_gcc-4.2.3/bin/gcc
--version
gcc (GCC) 4.2.3
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.