------- Comment #11 from vincent at vinc17 dot org 2008-08-19 01:31 ------- (In reply to comment #10) > If I replace the value 2 by 1 I still get the warning in GCC 4.4, so that > really sounds strange. Are you sure about that?
Yes and here Debian's GCC 4.4 snapshot has the same behavior as GCC 4.3.1 (also from Debian). Also, the optimized trees are not the same for 1 and 2. vin% cat tst.c void *foo (void); void bar (void *); void f (void) { int init = 0; void *p; while (1) { if (init == 0) { p = foo (); init = INIT; } bar (p); } } vin% gcc --version gcc.real (Debian 4.3.1-9) 4.3.1 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. vin% gcc -Wall -O2 tst.c -c -fdump-tree-optimized -DINIT=1 vin% cat tst.c.126t.optimized ;; Function f (f) Analyzing Edge Insertions. f () { void * p; <bb 2>: p = foo (); <bb 3>: bar (p); goto <bb 3>; } vin% gcc -Wall -O2 tst.c -c -fdump-tree-optimized -DINIT=2 tst.c: In function 'f': tst.c:7: warning: 'p' may be used uninitialized in this function vin% cat tst.c.126t.optimized ;; Function f (f) Analyzing Edge Insertions. f () { void * p; int init; <bb 2>: init = 0; <bb 3>: if (init == 0) goto <bb 4>; else goto <bb 5>; <bb 4>: p = foo (); init = 2; <bb 5>: bar (p); goto <bb 3>; } vin% /usr/lib/gcc-snapshot/bin/gcc --version gcc (Debian 20080802-1) 4.4.0 20080802 (experimental) [trunk revision 138551] Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. vin% /usr/lib/gcc-snapshot/bin/gcc -Wall -O2 tst.c -c -DINIT=1 vin% /usr/lib/gcc-snapshot/bin/gcc -Wall -O2 tst.c -c -DINIT=2 tst.c: In function 'f': tst.c:7: warning: 'p' may be used uninitialized in this function vin% -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36296