出乎意料的事情发生了

The*_* do 1 c++ exception

我正在尝试处理意外的异常,但无法使其工作.这是来自C++ Reference的示例

// set_unexpected example
#include <iostream>
#include <exception>
using namespace std;

void myunexpected () {
  cerr << "unexpected called\n";
  throw 0;     // throws int (in exception-specification)
}

void myfunction () throw (int) {
  throw 'x';   // throws char (not in exception-specification)
}

int main (void) {
  set_unexpected (myunexpected);
  try {
    myfunction();
  }
  catch (int) { cerr << "caught int\n"; }
  catch (...) { cerr << "caught other exception (non-compliant compiler?)\n"; }
  return 0;
} 
Run Code Online (Sandbox Code Playgroud)

他们说输出应该是:输出:

出乎意料的叫

抓住了

当我尝试时不会发生这种情况.我的输出是:
捕获其他异常(不兼容的编译器?)
我正在使用VS2010 sp1

Log*_*orn 6

文件unexpected说: C++标准要求,当一个函数抛出一个异常,是不是它的抛名单上意外被调用.目前的实施不支持这一点.
所以答案是VC10是一个不兼容的编译器.