Patchwork d_demangle_callback may use dc uninitialized, at least says gcc 4.3.2 Debian/powerpc

login
register
mail settings
Submitter Jay K
Date June 9, 2010, 4:07 p.m.
Message ID <COL101-W5693171BB9D477C959CA33E6D70@phx.gbl>
Download mbox | patch
Permalink /patch/55109/
State New
Headers show

Comments

Jay K - June 9, 2010, 4:07 p.m.
/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

Patch

--- /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')