Not sure if this is a bug, or I'm just missing some option or other, but I
appear to be missing "uninitialized variable" warnings (in some cases, but not
others) when compiling C such as the following:
#include
int
main(void)
{
int foo;
int i;
i = 1;
while (i) {
if (i == 10) {
foo = 50;
}
/* Uncomment this block and warnings miraculously appear
if (i == 15) {
foo = 52;
}
*/
if (foo) {
printf("%d\n", foo);
}
++i;
if (i > 20) {
break;
}
}
return 0;
}
I'm using the following to compile (which gives no output from gcc):
- /usr/bin/gcc -Wall -W -ansi -pedantic -O2 -o foo foo.c
And output from gcc -v gives this:
: gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.1-r3/work/gcc-4.1.1/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.1
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --disable-libunwind-exceptions
--disable-multilib --disable-libmudflap --disable-libssp --disable-libgcj
--enable-languages=c,c++,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.1 (Gentoo 4.1.1-r3)
Someone also tried the same code on 4.1.2 and got the same results (if that
helps).
--
Summary: gcc 4.1.1 missing uninitialized variable warnings
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: david dot cuthbert at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30542