Vector and deque initialization or push_back causes SIGABRT error

不想你离开。 提交于 2020-01-15 05:08:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!