On the Solaris build of the product it would core dump (crash) whenever there was an syntax error in the XML input files(It crashes on Solaris but not on Windows or Linux).
#include <iostream>
int main(int argc, char** argv)
{
try
{
std::cout << "About to throw exception." << std::endl;
throw;
}
catch(...)
{
std::cerr << "Exception caught." << std::endl;
}
return 0;
}
int main(int argc, char** argv)
{
try
{
std::cout << "About to throw exception." << std::endl;
throw;
}
catch(...)
{
std::cerr << "Exception caught." << std::endl;
}
return 0;
}
output:
About to throw exception.
Abort (core dumped)
About to throw exception.
Abort (core dumped)
Why it core dumps when throwing the exception?
这个用法本身是有问题的。throw;是重抛出,应该在catch块中被使用。
我找到的链接
http://developers.sun.com.cn/blog/wenlong/entry/200703099
我想solaris的行为是对的,转而应该研究为啥在windows和linux下不coredump
我找到的链接
http://developers.sun.com.cn/blog/wenlong/entry/200703099
我想solaris的行为是对的,转而应该研究为啥在windows和linux下不coredump
---
这个地址http://www.21ic.com/app/computer/200912/52021.htm
规则15-1-3(强制):空的 throw 语句只能出现在catch语句块中。
空的 throw 用来将捕获的异常再抛出,可以实现多个处理程序问异常的传递。然而,如果在catch语句外用,由于没有捕获到异常,也就没有东西可以再抛出,这样会导致程序以不定的方式终止(这依赖具体的编译器)。
规则15-1-3(强制):空的 throw 语句只能出现在catch语句块中。
空的 throw 用来将捕获的异常再抛出,可以实现多个处理程序问异常的传递。然而,如果在catch语句外用,由于没有捕获到异常,也就没有东西可以再抛出,这样会导致程序以不定的方式终止(这依赖具体的编译器)。