For the attached testcase, g++ gives a warning saying "`z' is used
uninitialized in this function" (_is_ used uninitialized, not _may be_ used
uninitialized)
in the statement marked with (***) below.  However, `z' is indeed
initialized by the mul() function template, which takes the first
argument by (non-const) reference:

template <typename To_Policy, typename From1_Policy, typename From2_Policy,
typename Type>
inline Result
add_mul_int(Type& to, const Type x, const Type y, Rounding_Dir dir) {
  Type z;
  Result r = mul<To_Policy, From1_Policy, From2_Policy>(z, x, y, dir);
  switch (r) {
  case V_NEG_OVERFLOW:
  case V_LT:
    if (to <= 0) {
      to = z;  (***)
      return r;
    }

To reproduce:

$ bunzip2 bug.cc.bz2 
$ md5sum bug.cc
bb3e86d1d865d1b661dd86da3456c909  bug.cc
$ g++ -Wall -O2 -c bug.cc
bug.cc: In function ‘void
Parma_Polyhedra_Library::add_mul_assign(Parma_Polyhedra_Library::Checked_Number<T,
P>&, const Parma_Polyhedra_Library::Checked_Number<T, P>&, const
Parma_Polyhedra_Library::Checked_Number<T, P>&) [with T = long int, Policy =
Parma_Polyhedra_Library::Checked_Number_Default_Policy]’:
bug.cc:37941: warning: ‘z’ is used uninitialized in this function
$ g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-13)
$ 

The file bug.cc.t28.ssa is 944683 bytes once compressed: I will attach it if
required.


-- 
           Summary: g++ says `z' is used uninitialized but this is not true
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bagnara at cs dot unipr dot it
  GCC host triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33802

Reply via email to