Vector and deque initialization or push_back cause

2019-07-16 01:45发布

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条回答
兄弟一词,经得起流年.
2楼-- · 2019-07-16 02:16

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.

查看更多
登录 后发表回答