vector destructor is calling _M_deallocate function, I would like to understand what it will do exactly here. Following calls tack is seen when it got crashed.
#5 deallocate (__a=..., __n=<optimized out>, __p=<optimized out>) at /usr/local/include/c++/5.4.0/bits/alloc_traits.h:517
#6 _M_deallocate (__n=<optimized out>, __p=<optimized out>, this=0x7f2b141451d0) at /usr/local/include/c++/5.4.0/bits/stl_vector.h:178
#7 ~_Vector_base (this=0x7f2b141451d0, __in_chrg=<optimized out>) at /usr/local/include/c++/5.4.0/bits/stl_vector.h:160
#8 ~vector (this=0x7f2b141451d0, __in_chrg=<optimized out>) at /usr/local/include/c++/5.4.0/bits/stl_vector.h:425
struct id
{
int mc[3];
int mn[3];
}ID;
typedef struct info
{
std::vector<ID*> ids;
}INFO;
std::vector<INFO*> info_list;
void fill_ids(ID id)
{
info_list.push_back(&id);
}
int main()
{
fill_ids(id);
/*after processing info_list. delete info_list*/
for (auto info_t : info_list)
{
delete info_t; //this line is causing for crash.
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire