I have an incorrect example program that should give one warning about an uninitialized variable, but when I compile it, gcc does not give me any warnings.
Here is the code:
#include <stdio.h>
int main()
{
int foo;
printf("I am a number: %d \n", foo);
return 0;
}
Here is what I run: cc -Wall testcase.c -o testcase
And I do not get feedback. As far as I know, this should produce:
testcase.c: In function 'main':
testcase.c:7: warning: 'foo' is used uninitialized in this function
He seems to have correctly warned Zed Shaw in a similar example in his textbook C). This is an example that I tried first and noticed that it does not work as expected.
Any ideas?
EDIT:
Gcc version:
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
source
share