I've searched several of the other Wunitialized reports, but without deeper knowledge, I wasn't able to conclude whether this is a dup.
Note that even if i happens to be zero-initialized, it is only in this strapped-down testcase. In the program I am hacking, I got an out-of-bound of roughly 2^31 over an array of 6 elements, pretty deep in a expression template hierarchy. ================================================================================ //Tested with (-Wall -Wextra): // * g++-4.3 (Debian 4.3.4-6) 4.3.4 // * g++-4.4 (Debian 4.4.2-9) 4.4.3 20100108 (prerelease) // * g++ (GCC) 4.5.0 20100306 (experimental) #include <iostream> int main () { int i; int array[10]; //std::cout << i; // get warning, okay for (; i<10; ++i) { // no warning std::cout << i; // no warning array [i] = i; // no warning, really hurts } // sidenote: same results for // for (int i; i<N; ++i) {...} } ================================================================================ Full triplets: Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.4-6' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.3.4 (Debian 4.3.4-6) Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.2-9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.3 20100108 (prerelease) (Debian 4.4.2-9) Using built-in specs. COLLECT_GCC=/usr/local/gcc-4.5-20100306/bin/g++ COLLECT_LTO_WRAPPER=/usr/local/gcc-4.5-20100306/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr/local/gcc-4.5-20100306 --enable-languages=c,c++ --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-checking --disable-nls --disable-multilib --enable-bootstrap --with-gcc --with-gnu-as --with-gnu-ld --with-gomp --with-lto Thread model: posix gcc version 4.5.0 20100306 (experimental) (GCC) -- Summary: [g++-4.3..g++-4.5] for-loops are in the way of Wuninitialized? Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: phresnel at gmail dot com GCC build triplet: (see details) GCC host triplet: (see details) GCC target triplet: (see details) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43361