使用MinGW 4.6.2(使用g++ -g -std=c++0x编译)编译以下内容,如果我尝试使用“catch throw”,gdb似乎无法捕获
std::out_of_range
。如果我手动throw
它,它可以正常捕获,我做错了什么吗?#include <stdexcept>
#include <vector>
int main()
{
std::vector<char> vec(10);
try {
vec.at(10); // this won't be caught by gdb
// throw std::out_of_range(""); // this will
}
catch (std::out_of_range const& e) {
}
}
break __throw_out_of_range
可以不需要指定文件和行号,用于std::unordered_map。标准的catch throw std::out_of_range
仍然不行。 - FDS