From patchwork Wed Jun 9 16:07:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: d_demangle_callback may use dc uninitialized, at least says gcc 4.3.2 Debian/powerpc Date: Wed, 09 Jun 2010 06:07:13 -0000 From: Jay K X-Patchwork-Id: 55109 Message-Id: To: gcc-patches /home/jay/src/gcc-4.5.0/libiberty/cp-demangle.c: In function ‘d_demangle_callback’: /home/jay/src/gcc-4.5.0/libiberty/cp-demangle.c:4767: warning: ‘dc’ may be used uninitialized in this function jay@plin:~/obj/gcc45$ gcc -v Using built-in specs. Target: powerpc-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --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 --disable-softfloat --enable-secureplt --enable-targets=powerpc-linux,powerpc64-linux --with-cpu=default32 --with-long-double-128 --enable-checking=release --build=powerpc-linux-gnu --host=powerpc-linux-gnu --target=powerpc-linux-gnu Thread model: posix gcc version 4.3.2 (Debian 4.3.2-1.1) jay@plin:~/obj/gcc45$ uname -a Linux plin 2.6.26-2-powerpc #1 Thu Feb 11 01:36:51 UTC 2010 ppc GNU/Linux The warning appears to be false:   enum     {       DCT_TYPE,       DCT_MANGLED,       DCT_GLOBAL_CTORS,       DCT_GLOBAL_DTORS     }   type;   struct demangle_component *dc; ...   if ...     type = DCT_MANGLED;   else if ...     type = ... ? DCT_GLOBAL_CTORS : DCT_GLOBAL_DTORS;   else ...       type = DCT_TYPE; ...     switch (type)       {       case DCT_TYPE:     dc = ...     break;       case DCT_MANGLED:     dc = ...     break;       case DCT_GLOBAL_CTORS:       case DCT_GLOBAL_DTORS:     ...     dc = ...     break;       }       Nevertheless: jbook2:~ jay$ diff -u /Users/jay/src/orig/gcc-4.5.0/libiberty/cp-demangle.c /Users/jay/src/gcc-4.5.0/libiberty/cp-demangle.c Appears same in gcc trunk. Optimization at least with better/newer compiler should remove the initialization but I didn't check.  - Jay --- /Users/jay/src/orig/gcc-4.5.0/libiberty/cp-demangle.c    2010-03-22 13:38:35.000000000 -0700 +++ /Users/jay/src/gcc-4.5.0/libiberty/cp-demangle.c    2010-06-09 09:00:09.000000000 -0700 @@ -4764,7 +4764,7 @@      }    type;    struct d_info di; -  struct demangle_component *dc; +  struct demangle_component *dc = { 0 };    int status;      if (mangled[0] == '_' && mangled[1] == 'Z')