views:

212

answers:

2

Hi,

I am trying to use a class member that uses nested vectors of depth 3:

vector< vector< vector > > classVariable_;

However, I then get compiler warnings throughout my code when I try do something as simple as classVariable_.clear():

/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h: In member function `std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector >, _Alloc = std::allocator > >]': /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h:715: warning: '__result' might be used uninitialized in this function /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82: warning: '__cur' might be used uninitialized in this function /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82: warning: '__cur' might be used uninitialized in this function

The strange thing is that this works with nested vectors of depth 2, but not of depth 3 or more. Is this something to do with missing default operators/constructors in the stl libraries?

Does anyone know a clean solution around this? I am compiling this using cygwin but that should not have an effect on this.

Thank you.

+3  A: 

If you actually mean vector< vector< vector< int> > > classVariable_, then classVariable_.clear() shouldn't produce any warning. Might be this bug.

Disable the warning manually, or avoid nested vectors of depth 3, which might not be a good idea anyway.

Samuel_xL
You were right, it was a gcc bug. I upgraded from gcc 3.4.4 to 4.3.2 and the warnings are all gone.Thanks!
bsofman
A: 

If they are just warnings I don't think it can be anything major, but the warnings are for _result and _cur not being initialized.

Maybe try clearing the lowest level vector and work your way back up?

Brandon Haugen