title: Constructor as a function try block - Exception aborts program
body: <p>I am not sure if this is a issue with the compiler or if I am doing something wrong. I am using Visual Studio 2013 compiler.</p>
  
  <p>I have a class where I need to acquire significant amount of resources in my constructor initializer list most of which can throw an exception. I wrapped up the member initializer list in a function try block and caught the exception there. But my program still aborts even though the catch clause doesn't re-throw the exception. I am not allowed to post the actual code. So I have reproduced the issue with this equivalent demo code. Can someone please help me address this?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  class A{
  public:
      A() try : i{ 0 }{ throw 5; }
      catch (...){ cout &lt;&lt; "Exception" &lt;&lt; endl; }
  private:
      int i;
  };
  
  
  int main(){
      A obj;
  }
  </code></pre>
  
  <p>On executing this code I get a windows alert "abort() has been called". So I guess the system is treating this as an uncaught exception and calling terminate(). </p>
  
  <p>On the other hand if I wrap the construction of the object in main() in a try-catch block then the exception is caught properly and the program terminates normally.</p>
  
  <p>Can someone please tell me if I am doing something wrong here?</p>