#include void allocate_it(int x) try { int i; for (i = 0 ; i < x ; ++i) { new int[0x100000]; } } catch(...) { std::cout << "caught exception when allocating " << x << " blocks of memory" << std::endl; // std::cout << "failure occurred on iteration " << i << std::endl; // standard [3.4.1], function parameters are accessible in handler of function try block // but local variables of the function are NOT accesible } int main(int argc, char** argv) { allocate_it(5000); return 0; }