如何修复此错误?在抛出 'std::bad_alloc' what() 的实例后终止调用: std::bad_alloc
How I can fix this error? terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
这是代码:功能:
QString printDir2(QString path, int level)
{
int check =1;
QDir folder(path);
QString space;
QString buffer;
qDebug() <<"nivelul 1 n";
for(int i=0; 1<level; i++)
space +=" ";
qDebug() <<"nivelul 2 n";
foreach(QFileInfo temp , folder.entryInfoList())
{
if(check > 2)
{
qDebug() <<"nivelul 4 n";
buffer += space + temp.absoluteFilePath() + "n";
if(temp.isDir())
buffer += printDir2(temp.absoluteFilePath(), ++level);
}
check++;
qDebug() <<"nivelul 3 n";
}
return buffer;
}
在这里,我调用该函数:
QString drum="/home/sunny/Desktop/QT/descarca";
str=printDir2(drum,0);
qDebug()<<str<<"acesta este drumul";
如何从终端修复此 erorr:
在抛出 'std::bad_alloc' 的实例后调用终止 what(): std::bad_alloc这是我运行代码时的终端:http://s013.radikal.ru/i325/1501/e5/aade9346f0aa.png
你可能遇到了无限递归。
在调试器中运行程序。如果使用 gdb,则可以在 run
之前发出命令 catch throw
。然后,当引发异常时,调试器将停止。您可能需要up
移动几次才能查看代码中的哪一行引发了异常。
相关文章:
- 使用来自 Excel VBA 的 C++ dll 时"Bad DLL calling convention" - 如何解决?
- C++17 编解码器在将标准::字符串转换为标准::字符串时抛出"bad conversion"
- 对于代理容器上的迭代器来说,"least bad implementation"可能是什么?
- 组件对象模型 (COM):IMalloc::Alloc 在哪里分配内存?
- 获取错误:在抛出"std::bad::alloc"的实例后终止调用 what(): std::bad_alloc
- 为什么 GetSystemMetrics (SM_CXVIRTUALSCREEN) 返回'bad'值?
- 将 lambda 传递给 STL 集时出错"bad function call"
- 新的 C++14 位分隔符处"Bad Character" Eclipse Oxygen 错误
- 使用 #define 被认为是"bad practice"吗?
- "400 Bad request"使用 OpenSSL BIO 进行请求时
- CGAL:Hausdorff距离不良Alloc
- 解密文件AES_256_CBC返回"bad decrypt"错误
- 在C++流中,eof(),fail(),bad()和good()有什么区别
- C STD ::初始化类对象中的Alloc错误错误
- make / gcc:"bad build"的可能原因是什么?
- 什么是地址0xbaddc0dedeadbead "Bad decode dead bead"
- 在多线程环境中,什么可能导致"bad file descriptor"?
- 尝试解决HackerBank上的BFS挑战时出现错误的alloc异常
- "std::vector"在调整大小时引发"bad allocation"异常
- 尝试使用 execp、dup2 和管道实现 shell,挂起或"bad file descriptor"