September 12
which is so wrong and bad and wrong it makes me apoplectic
有兴趣的话,大家猜测一下下面这段程序的输出是什么。
猜测完了后,请在vs2003, vs2005下面分别进行测试。测试分下面2*2交叉情况:
1. Compile with /EHa
2. Compile with /EHsc
3. Compile in debug mode
4. Compile in release mode
class clstest
{
public:
~clstest()
{
printf("clstest desc");
}
};
void testcase1()
{
__try
{
throw 1;
}
__except(1)
{
printf("in desc\n");
throw 2;
}
};
void testcase2()
{
try
{
clstest c2;
int *p=0;
*p=0;
}
catch(...)
{
printf("in catch\n");
}
};
int _tmain(int argc, _TCHAR* argv[])
{
__try
{
testcase2();
testcase1();
}
__except(1)
{
printf("in main\n");
}
return 0;
}
按照dev的话说(标题),就是vs2005以前的这个bug,是愚蠢的错误,错误得简直让人中风!