Crash when NCollection_Vector is member


I have a quite complicated question, but I would be glad, if someone could share experience:

One of my classes has a member field of type NCollection_Vector. When an exception is thrown during the constructor of this own class, the application crashes with a segmentation fault in the method initMemBlocks of NCollection_Vector, which is called by the destructor of NCollection_Vector. The line causing troubles is line 306 of NCollection_Vector.hxx in my revision. It states:

anAllocator->Free (theBlock.DataPtr);

Has anyone ever had trouble like this? What is the reason? That the construction of NCollection_Vector was not completed because of the exception and now the destruction fails, because the destructor is trying to clean up something, that has never been initialized? How can I work around this?

As far as I know it is not necessarily bad style to throw exceptions in constructors of C++ classes, is it?

Thank you very much for any help!!!


Benjamin Bihler's picture

This post was nonsense, I am sorry! I had not understood the real problem when I wrote it. My real issue is now described in a new post with the subject "Constructor creating this-handle must succeed!".