I'm going crazy with crash on deleting object with a vector inside.

I have this structure :
1
2
3
4
5
6
7
8
9
struct W_sup {   
    W_sup_header header;  
    vector<Tpun>  V_pnt; 
    vector<float> V_pnt3df;  
    vector<Tcod>  V_cod; 
    vector<Tsym>  V_sim; 
    vector<Ttxt>  V_tex; 
    W_sup(){};  ~W_sup(){    };
};


Ok,next I have a class that has a vector of W_sup inside:

1
2
3
4
5
6
7
8
class W_perfil {
  public :
  W_perfil();
  ~W_perfil();
  W_perfil_header header;
  vector<W_sup>   V_sups;   

};


Inside a class I have a private *w_perfil and *w_sup:
My code inside a do-while:
1
2
3
4
5
w_perfil = new W_perfil;
w_sup    = new W_sup;
w_perfil->V_sups.push_back(*w_sup);
delete w_sup;
delete w_perfil;


I have a crash when I try to delete w_perfil with this log:

6 __gnu_cxx::new_allocator<float>::deallocate new_allocator.h 95 0x470cad
7 std::_Vector_base<float, std::allocator<float> >::_M_deallocate stl_vector.h 146 0x479cf1
8 std::_Vector_base<float, std::allocator<float> >::~_Vector_base stl_vector.h 132 0x479db7
9 std::vector<float, std::allocator<float> >::~vector stl_vector.h 314 0x485b7c
10 W_sup::~W_sup w_clases.h 147 0x46c0c7
11 std::_Destroy<W_sup> stl_construct.h 89 0x490e41
12 std::_Destroy_aux<false>::__destroy<W_sup*> stl_construct.h 99 0x47768b
13 std::_Destroy<W_sup*> stl_construct.h 122 0x4912f8
14 std::_Destroy<W_sup*, W_sup> stl_construct.h 148 0x491314
15 std::vector<W_sup, std::allocator<W_sup> >::_M_erase_at_end stl_vector.h 1154 0x480302
16 std::vector<W_sup, std::allocator<W_sup> >::clear stl_vector.h 955 0x48036a
17 W_perfil::~W_perfil w_trans.cpp 50 0x424073



I dont create any data to the vector<float> V_pnt3df, so I dont undertstand nothing ....
Any idea about what is happen?
Thanks
Last edited on
You'll have to post more code.

But I don't understand why you do line 2 and 4 instead of just doing

 
w_perfil->V_sups.push_back( W_sup() );

I cant post more code.....
But.... forget it, my problem is deeper .
Thanks
Topic archived. No new replies allowed.