Tried this on two machines: SunOS hornet 5.10 Generic sun4u sparc SUNW,Ultra-4 with GCC 4.0.1 Linux numenor 2.6.13 #9 Mon Sep 19 19:03:35 PDT 2005 i686 unknown unknown GNU/Linux with GCC 3.3.6 The following code produces spurios warning: /* Cut here */ int x_read(int h, void *buf, unsigned len); int x_write(int h, const void *buf, unsigned len); typedef int (*x_io)(int h, void *buf, unsigned len); int blockio(int h, long long offset, void *buf, x_io action); int bug(int h, unsigned where, void *buf) { return blockio(h, (long long)where << 10, buf, x_write); } /* Cut here */ sample.c: In function `bug': sample.c:9: warning: passing arg 4 of `blockio' from incompatible pointer type
The warning is correct. The type of x_write is incompatible with x_io, because "const void *" is incompatible with "void *". Argument promotion does not come into play here.
Aren't function arguments contravariant rather than covariant?
No, in C, these are two different function types.
Reoepening to ...
To Close as a dup of bug 16895. *** This bug has been marked as a duplicate of 16895 ***