来自std :: _ Rb_tree_increment的分段错误(__x = 0x1)

时间:2012-01-27 14:27:57

标签: c++ iterator set

迭代一组时出现分段错误。堆栈跟踪指向   在/libstdc++/scrc/tree.cc:68的std :: _ Rb_tree_increment(__ x = 0x1)中的0x000000081193ccc5   0x00000806c3107e在std :: _ Rb_tree_const_iterator :: operator ++中的stl_tree.h:266

但我没有得到更多信息,但崩溃的最后一行如下。迭代器已经过了一套。

  typedef std::set<test*,test_less> test_set_t;

  test_set_t& set(bt->getSet());   // getSet() will return reference to the class bt member variable set

 test_set_t::iterator pos = set.begin();

 test empty(val);
 test* last_ptr = &empty;

 for (; pos != set.end(); last_ptr = *pos++) {       // gdb shows this as last line

我看不出这个问题。提前谢谢。

1 个答案:

答案 0 :(得分:2)

很可能该集合为空或您删除了迭代时指向的项pos