I create an object in allocated space and it immediately after calls its own destructor, I can use the Object after, but it messes up the object because destructor deletes internal pointers and does cleaning.
// prepare pointer SomeObject *objs; // allocate memory void* memory = malloc(sizeof(SomeObject)*5); // point to memory as SomeObject pointer objs = (SomObject*)memory; // try to create object in third(out of five) memory slot objs = SomeObject(); // later use is messed up because destructor has been called.
I found out that this was indeed the case by putting "std::cout"s in both constructor and destructor to tell when they are called.
This is as low as was possible to debug. Does anyone happen to know why this happens ?