This is probably pretty dodgy C code, but I find it strange that program foo.c compiles while program bar.c gives an error. Is this a bug? ----------- foo.c -------------- #include <stdio.h> int main() { int ii; ii = 276; void *vv = (void *)ⅈ } ----------- foo.c -------------- ----------- bar.c -------------- #include <stdio.h> int main() { int ii; void *vv; ii = 276; *vv = (void *)ⅈ } ----------- bar.c -------------- % gcc -o foo foo.c % gcc -o bar bar.c bar.c: In function ESC)B?main?: bar.c:10: warning: dereferencing ESC)B?void *? pointer bar.c:10: error: invalid use of void expression % For completeness on this report, this was on % gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: /usr/local/gcc-4.0.2/src/gcc-4.0.2/configure --enable-languages=c --prefix=/usr/local/gcc-4.0.2/x86-Linux Thread model: posix gcc version 4.0.2 %
The first one is ok C even though it is not OK C89 but it is fine C99. The second one is not ok C at all, since you are deferencing a void pointer.