开发者

Debug assertion failure in C++

开发者 https://www.devze.com 2023-01-07 13:09 出处:网络
This is my first ques开发者_如何学编程tion on stackoverflow. I am trying to debug a program but when I try to run it, it terminates with error message

This is my first ques开发者_如何学编程tion on stackoverflow.

I am trying to debug a program but when I try to run it, it terminates with error message Debug Assertion failed and when I retry to debug it a break-point is created which takes me to vector in this function

#if _HAS_ITERATOR_DEBUGGING
 _Vector_const_iterator(_Tptr _Ptr, const _Container_base *_Pvector)
  { // construct with pointer _Ptr
  _SCL_SECURE_VALIDATE(_Pvector == NULL || (((_Myvec *)_Pvector)->_Myfirst <= _Ptr && _Ptr <= ((_Myvec *)_Pvector)->_Mylast));
  this->_Adopt(_Pvector);
  _Myptr = _Ptr;
  }

and this line

_SCL_SECURE_VALIDATE(_Pvector == NULL || (((_Myvec *)_Pvector)->_Myfirst <= _Ptr && _Ptr <= ((_Myvec *)_Pvector)->_Mylast));

Please suggest where the problem might be and where to look. Is it some problem with iterator I am using.

Thanks


I think you should post your code, but not the STL assertion code (obviously this one isn't the easiest to investigate :)

Anyway, this assertion message usually indicates an attempt to access wrong index (out of bounds) or the similiar write operation in your std::vector or some wrapper around it.

This could also be caused if you store iterators which become invalidated after, for example, after a sequence of insertions.


Can you post the code of yours which is triggering this error? It seems like their debug check (likely bounds or something similar) is failing, but that assertion would only fail if the input to the function is somehow problematic. For us to really assist you any further we'll need to see the code that invokes this behavior.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号