我正在用C++编写程序.该程序已经适用于Win32(x86),最近我尝试为x64本地编译它.当然,东西不能马上工作.
在调试问题后,我设法使用这个简单的代码片段重现它:
class MyException { };
int main()
{
try {
for (;;) {
try {
std::cout << "Throwing" << std::endl;
throw MyException();
if (1 == 0) {
continue;
}
} catch (const MyException&) {
std::cout << "Catch 1" << std::endl;
}
}
} catch (const MyException&) {
std::cout << "Catch 2" << std::endl;
}
std::cout << "Done" << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
(我很快就会解释这if (1==0)条款)
使用MSVC for x86编译此代码时(我使用过2010),结果如预期:
Throwing
Catch 1
Throwing
Catch 1
Throwing
Catch 1
Throwing …Run Code Online (Sandbox Code Playgroud)