Package: gcc Version: 1:2.95.2-13 Severity: normal
-- System Information Debian Release: 2.2 Kernel Version: Linux chiark 2.2.19 #10 SMP Fri Oct 19 11:12:23 BST 2001 i686 unknown Versions of the packages gcc depends on: ii binutils 2.9.5.0.37-1 The GNU assembler, linker and binary utiliti ii cpp 2.95.2-13 The GNU C preprocessor. ii libc6 2.1.3-17 GNU C Library: Shared libraries and Timezone (Wall includes Wunitialized, but I included both as "belt and braces".) chiark:~/gcc-problem:12$ gcc -c -g -O3 -Wall -Wuninitialized warning-test.c -o warning-test -DMHP_TEST_WARNING chiark:~/gcc-problem:13$ Doesn't give any warning about the timeout not being initialised. (I've tried with varying -O options, and with and without -c, none help.) If I remove the never used sscanf it does. (Note ptr is set to NULL and never changed.) chiark:~/gcc-problem:11$ gcc -c -g -O3 -Wall -Wuninitialized warning-test.c -o warning-test warning-test.c: In function `main': warning-test.c:8: warning: unused variable `ptr' warning-test.c:6: warning: `timeout' might be used uninitialized in this function This may be related to a bug reported in gcc 2.95 on the gcc Gnatsweb (PR 179) at http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=179. As I am unsure I thought I'd report it anyway. warning-test.c follows: #include <stdio.h> #include <stdlib.h> int main (int argc, char ** argv) { int timeout, timeout_offset; int rv; char * ptr = NULL; timeout_offset = 100; #ifdef MHP_TEST_WARNING if (ptr) { sscanf(ptr+timeout_offset, "%d", &timeout); printf("Found timeout\n"); } #endif rv = timeout; return rv; }