This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/19510] New: [4.0 regression] Warning using list iterators


Compiling the following code snippet with "-Wall -O3" using mainline

===============================================
#include<vector>
#include<list>

std::vector<std::list<int>::iterator> v(1);
===============================================

I get the following warning:

/long_path/stl_construct.h: In function 'void
__static_initialization_and_destruction_0(int, int)':
/long_path/stl_construct.h:81: warning: 'SR.133' is used uninitialized in this
function

Apart from the strange variable name 'SR.133' the warning seems to be
justified as the default constructor of _List_iterator does not initialize
the pointer _M_node. _List_const_iterator has the same problem.

The following patch fixes the problem for me.
I haven't done bootstrapping and regtesting, though.

===================================================================
--- libstdc++-v3/include/bits/stl_list.h	19 Nov 2004 12:44:09 -0000	1.45
+++ libstdc++-v3/include/bits/stl_list.h	18 Jan 2005 18:49:06 -0000
@@ -119,7 +119,8 @@ namespace _GLIBCXX_STD
       typedef _Tp*                          pointer;
       typedef _Tp&                          reference;
 
-      _List_iterator() { }
+      _List_iterator()
+      : _M_node() { }
 
       _List_iterator(_List_node_base* __x)
       : _M_node(__x) { }
@@ -195,7 +196,8 @@ namespace _GLIBCXX_STD
       typedef const _Tp*                    pointer;
       typedef const _Tp&                    reference;
 
-      _List_const_iterator() { }
+      _List_const_iterator()
+      : _M_node() { }
 
       _List_const_iterator(const _List_node_base* __x)
       : _M_node(__x) { }
===================================================================

-- 
           Summary: [4.0 regression] Warning using list iterators
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]