我有一个deque<rect*> rects
whererect
是用户定义的类。当我尝试进入它时,我遇到insert
了rect*
分段错误。gdb
将问题追溯到__memmove_sse3()
我调用rects.insert(it,new rect([constructor parameters]));
where it
is a时调用的函数deque<rect*>::iterator
。什么可能导致此错误?
编辑:这是我的代码片段:
for(deque<rect*>::iterator it=rects.begin();it!=rects.end();++it)
{
rect r=*r1;
rect r2=*(*it);
if(!r2.there)
continue;
if(r.down>r2.up || r.up<r2.down || r.right<r2.left || r.left>r2.right)
continue;
if(r.left>r2.left)
rects.insert(it,new rect(r2.left,r2.down,r.left,r2.up,r2.color));
if(r.right<r2.right)
rects.insert(it,new rect(r.right,r2.down,r2.right,r2.up,r2.color));
if(r.up<r2.up)
rects.insert(it,new rect(max(r.left,r2.left),r.up,min(r.right,r2.right),r2.up,r2.color));
if(r.down>r2.down)
rects.insert(it,new rect(max(r.left,r2.left),r2.down,min(r.right,r2.right),r.down,r2.color));
r2.there=false;
}