Warning on cast to const

clifford@clifford.at clifford@clifford.at
Mon Mar 29 06:36:00 GMT 2004


Hi,

maybe I am wrong, but in my understanding an implicit cast from non-const
to const should never produce a warning (and usually does not), but:

root@murphy:~# cat demo.c
void func(const char **p) { }
int main() {
        const char **demo1=0;
        char **demo2=0;
        func(demo1);
        func(demo2);
}

root@murphy:~# gcc-x demo.c
demo.c: In function `main':
demo.c:6: warning: passing arg 1 of `func' from incompatible pointer type

root@murphy:~# gcc-x --version
gcc-x (GCC) 3.4.0 20040317 (prerelease)

this happens with all gcc releases I've tested (that's back to 2.95.3). Do
I miss-understand anything or is this a gcc bug?

There is no warning with "const char *p" or "const char p". Only **p and
even more reference-levels trigger the warning.

yours,
 - clifford

-- 
| Clifford Wolf /-----=[ www.clifford.at ]==[ Tel: +43-699-10063494 ]=-\
|--------------/ diestartseite.at vocat.cc =[ Fax: +43-2235-42788-4 ]=-|
|-=[ EDEN Creations -- www.edenevents.at ]==[ IRC: www.freenode.net ]=-|
\==[ www.rocklinux.org ]===[ www.rocklinux.net ]===[ www.linbit.com ]==/

2B OR (NOT 2B) That is the question. The answer is FF.



More information about the Gcc mailing list