我使用的是QT5.12.3,Qt Creator编辑器,VS2017的构建套件,VC++ amd64编译器:
下方这段看似会崩溃的代码,实际不会崩溃:
QList<int> list;
list.append(0);
list.append(3);
list.append(5);
list.append(6);
list.append(7);
list.append(8);
int cnt = list.count();
for (int i = 0; i < cnt; i++)
{
qCritical() << "开始时数量--" << list.count() << "i=" << i << "list->" << list;
int vel = list[i];//超范围索引,不会崩溃
list.removeAll(vel);
qCritical() << "结束时数量--" << list.count() << "取出的数据:" << bondPos;
}
在debug中,会报如下错误:
release中不会报错: