
19 May
2009
19 May
'09
5:37 a.m.
Here's a perfectly legal, perfectly defined C++03 program in a single module with a single thread that has a runtime-determined number of exceptions:
#include <iostream>
void fun(int recursions);
int main() { int n; std::cin >> n; fun(n); }
void fun(int recursions) { try { throw 0; } catch(int) { fun(recursions - 1); } }
Actually you must use the exception object in the catch so that the compiler cannot optimize it away. So this example is not correct. :) Adam Badura