Hi I have a strange problem that std::vector<>'s constructor is throwing an out_of_range exception. The exception reads like:
First-chance exception at 0x000007fefde09e5d in 3dsmax.exe: Microsoft C++ exception: std::out_of_range at memory location 0x6726ee40..
Which isn't very helpful anyway. In the debugger, the code reads like:
std::vector<Point3> points;
std::vector<Point3> normals;
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. 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. The "Point3" class is defined in 3dsmax SDK which looks like:
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& a) {
x = a.x; y = a.y; z = a.z;
}
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.
I'm using VisualStudio 2008 with windows 7. Any idea of how to fix this problem? thanks.
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)
Update: Tried to move the two local variables from stack to heap (using new) and the problem persisted.