EXC_BAD_ACCESS (code=1, address=0x10))??在这种情况下这意味着什么
EXC_BAD_ACCESS (code=1, address=0x10))??? What does this mean in this context?
我正在构建一个遗传算法,我有一个问题。这是一个记忆的问题,我仍然是新的和malloc的东西,我需要使用它吗?如果有人能解释一下这个错误,我将不胜感激。在K的第4个增量之后,我得到EXC_BAD_ACCESS (code=1, address=0x10)的错误。它会卡在
tmp.at(0) = it_1->first;
void Population::Poppairing(int j)
{
int rand_num = 0;
int rand_per = 0;
for (unsigned long i = select.size(); i-=2;)
{
rand_per = rand()%100;
if(j < rand_per)
{
auto temp_1 = parents.at(select.at(i)).get_genome();//auto here is unordered map
auto temp_2 = parents.at(select.at(i-1)).get_genome();
auto it_1 = temp_1.begin();//here it is and iterator
auto it_2 = temp_2.begin();
for(int k = 0;k < no_rule; k++)
{
rand_num = rand() % no_in;
advance(it_1,k);
advance(it_2,k);
vector<string > tmp(2);
for(int l = 2; l--;)
{
tmp.at(0) = it_1->first;//father
tmp.at(1) = it_2->first;//mother
tmp.at(l).erase((tmp.at(l).begin()+rand_num),tmp.at(l).end());
tmp.at((!l)).erase(tmp.at((!l)).begin(),(tmp.at((!l)).end()-((tmp.at(!l)).size()-rand_num)));
children.at(i-l).set_input_pos((tmp.at(l)+tmp.at(!l)),k);
children.at(i-l).set_output_pos((unsigned char)(parents.at(i-l).get_genome().begin()->second),k);
}
tmp.clear();
}
children.at(i).re_initialising_map();
children.at(i-1).re_initialising_map();
}
else
{
children.at(i) = parents.at(select.at(i));
children.at(i-1) = parents.at(select.at(i-1));
}
}
}
我修复了它,似乎从iterator
stl
使用advance
有问题。只是增加了k for循环末尾的it_1和2。
相关文章:
- 这行代码在C++类中意味着什么
- 这对"With a stackless coroutine, only the top-level routine may be suspended."意味着什么
- @CPPFLAGS@在 Makefile.in 中意味着什么?
- 生成文件"relink"意味着什么?
- 从二进制流中读取时,将双精度变量的地址转换为 char* 意味着什么?
- 在这种情况下,"typename..."意味着什么?
- "in-situ without memory allocation" 字符串的愚蠢实现意味着什么?
- 使用typedef有什么用,它意味着什么
- GCC 的 -Wpsabi 选项究竟有什么作用?压制它意味着什么?
- 这在C++ "It does not own the underlying data, and so is cheap to copy or assign"中意味着什么
- 由于某种原因,我的代码中出现了 [json.exception.type_error.302]。我知道错误意味着什么,但我不知道哪里有故障
- 调用堆栈显示 SIGBUS,这意味着什么
- C++标准在[basic.scope.hiding]中"same scope"到底意味着什么?
- 评估对象的创建意味着什么?
- 当我们在 C++ 中说"initialize the object"时,它实际上意味着什么?
- C++这种结构"InterceptionKeyStroke &kstroke = * (InterceptionKeyStroke *) &stroke"意味着什么?
- 该语法在C 中意味着什么
- 链接标志对静态库意味着什么
- 由mpglib输出的"hip: Can't rewind stream by 74 bits"到底意味着什么?
- 这在 C# 中意味着什么以及如何使用它