public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33802]  New: g++ says `z' is used uninitialized but this is not true
@ 2007-10-17 18:39 bagnara at cs dot unipr dot it
  2007-10-17 18:41 ` [Bug c++/33802] " bagnara at cs dot unipr dot it
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: bagnara at cs dot unipr dot it @ 2007-10-17 18:39 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2320 bytes --]

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


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-02-04 20:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-17 18:39 [Bug c++/33802] New: g++ says `z' is used uninitialized but this is not true bagnara at cs dot unipr dot it
2007-10-17 18:41 ` [Bug c++/33802] " bagnara at cs dot unipr dot it
2007-10-17 18:46 ` pinskia at gcc dot gnu dot org
2007-10-17 21:23 ` rguenth at gcc dot gnu dot org
2007-12-22 18:03 ` manu at gcc dot gnu dot org
2008-01-07 19:48 ` bagnara at cs dot unipr dot it
2008-01-07 19:48 ` bagnara at cs dot unipr dot it
2008-01-07 19:50 ` bagnara at cs dot unipr dot it
2008-02-01 16:29 ` manu at gcc dot gnu dot org
2008-02-01 16:30 ` [Bug c++/33802] bogus "is used uninitialized" (VOPs) (inlining) manu at gcc dot gnu dot org
2008-02-01 16:49 ` rguenth at gcc dot gnu dot org
2008-02-01 18:16 ` manu at gcc dot gnu dot org
2008-02-01 18:21 ` manu at gcc dot gnu dot org
2008-02-04 20:38 ` manu at gcc dot gnu dot org
2008-02-04 20:40 ` manu at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).