Output of gcc -v: Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.0.0/configure --prefix=/home/williamg/local/x86_64-40 --enable-__cxa_atexit --enable-languages=c,c++ Thread model: posix gcc version 4.0.0 Command line: ~/local/x86_64-40/bin/gcc -O1 -Wall -Werror -c 3.c -o 3.o Output: cc1: warnings being treated as errors 3.c: In function ‘main’: 3.c:6: warning: ‘initialised_when_a_is_non_zero’ may be used uninitialized in this function Preprocessed source: # 1 "3.c" # 1 "<built-in>" # 1 "<command line>" # 1 "3.c" extern int g (int); int main () { const int a = g (0); int initialised_when_a_is_non_zero; if (a) initialised_when_a_is_non_zero = 10; g (1); if (a) g (initialised_when_a_is_non_zero); return 0; } It's clearly impossible that we use initialised_when_a_is_non_zero unless it has been initialised. The warning does not appear with -O0. Removing the line "g (1);" also makes the warning disappear.
-- Summary: Erroneous warning: " ... may be used uninitialized in this function" Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: william at gallaf dot net CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21358