问题
I'm getting a weird error, when initializing my deque or vector. I'm using QtCreator and a CMake-Project.
If I use a deque, it aborts on initialization:
std::deque<int> myValues; // <-- abort here
for (int i=0;i<10;++i)
{
myValues.push_back(i);
}
when I use deque, it aborts on push_back:
std::vector<int> myValues;
for (int i=0;i<10;++i)
{
myValues.push_back(i); // <-- abort here
}
I can't find out why this is happening now (it worked that way all the time). Both aborts happen inside _gnu_cxx::new_allocator< int >::allocate.
Any hints?
Thanks for the effort in advance!
Hartmut
回答1:
It looks like a heap corruption in some other place in your program. That is, you write out-of-bounds or delete an invalid pointer somewhere. Once the heap internal structure is corrupted, substantial allocations may crash your program.
来源:https://stackoverflow.com/questions/11308905/vector-and-deque-initialization-or-push-back-causes-sigabrt-error