On 8/2/06, Mike McCormack mike@codeweavers.com wrote:
["void *foo" is better than "void *foo = NULL", you want it to remain uninitialized because that way the compiler will warn]
gcc version 4.1.2 20060729 (prerelease) (Debian 4.1.1-10)
mike@black:~/wine$ cat foobar.c void foo(int *); void bar(void) { int x; if(x) foo(&x); } mike@black:~/wine$ gcc -Wall -c foobar.c mike@black:~/wine$
Superior, if the compiler did happen to warn you...
No fair, Mike, you should have given the link to the PR: http://gcc.gnu.org/PR19430
Many similar errors will get caught, as long as you turn on the optimizer with -O (otherwise the compiler can't detect them).
It does warn on the use of x as long as you avoid the specific case of PR19430. For instance:
$ cat foobar.c void foo(int *x); void bar(void) { int x; int y; if (x) foo(&y); } $ gcc -O -Wall -c foobar.c foobar.c: In function `bar': foobar.c:2: warning: `x' might be used uninitialized in this function
Thanks for pointing out that bug. I'll nag some compiler folk about it. - Dan