title: C++ vector constructor throws std::out_of_range exception (Microsoft C++ stdlib)
body: <p>Hi I have a strange problem that std::vector&lt;>'s constructor is throwing an out_of_range exception. The exception reads like:</p>
  
  <pre><code>First-chance exception at 0x000007fefde09e5d in 3dsmax.exe: Microsoft C++ exception: std::out_of_range at memory location 0x6726ee40..
  </code></pre>
  
  <p>Which isn't very helpful anyway. In the debugger, the code reads like:</p>
  
  <pre><code>std::vector&lt;Point3&gt; points;
  std::vector&lt;Point3&gt; normals;
  </code></pre>
  
  <p>and the exception is coming from the second line. These are two local variables, means that they're in a member function body, and was called multiple times. <strong>The exception doesn't happen when these two constructors were first called, but always throws when the second line (normals) were hit for the second time.</strong> The "Point3" class is defined in 3dsmax SDK which looks like:</p>
  
  <pre><code>class GEOMEXPORT Point3: public MaxHeapOperators {
  
  public:
  float x,y,z;
  
  // Constructors
  /*! \remarks Constructor. No initialization is performed. */
  Point3() { /* NO INIT */ }
  /*! \remarks Constructor. x, y, and z are initialized to the values specified. */
  Point3(float X, float Y, float Z)  { 
       x = X; y = Y; z = Z; 
   }
  /*! \remarks Constructor. x, y, and z are initialized to the specified values (cast as floats). */
  Point3(double X, double Y, double Z) { 
       x = (float)X; y = (float)Y; z = (float)Z; 
   }
  /*! \remarks Constructor. x, y, and z are initialized to the specified values (cast as floats). */
  Point3(int X, int Y, int Z) { 
       x = (float)X; y = (float)Y; z = (float)Z; 
   }
  /*! \remarks Constructor. x, y, and z are initialized to the specified Point3. */
  Point3(const Point3&amp; a) { 
       x = a.x; y = a.y; z = a.z; 
   } 
  </code></pre>
  
  <p>You can find this class in Point3.h in 3ds max sdk. It only have 3 floats inside it and seems to have enough various type of constructors. I can't believe there is problem in this class.</p>
  
  <p>I'm using VisualStudio 2008 with windows 7. Any idea of how to fix this problem? thanks.</p>
  
  <p>Update: Yes, it's a First-chance exception, but it's not handled in STL and directly poped up to crash my application. (And I can catch this exception in my own code if I warp that scope with try-catch)</p>
  
  <p>Update: Tried to move the two local variables from stack to heap (using new) and the problem persisted.</p>