I would need a bit of help on fixing a problem : apparently I'm doing something wrong when implementing the opAssign operator.
Here is a short and easily reproducible piece of code that, for some reason, crashes :
struct test
{
test copy(test other) { std::cout << "test2" << std::endl; thing = other.thing; return (other); }
int thing;
};
int main(void)
{
asIScriptEngine* engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
const char* testClass = "Test";
engine->RegisterObjectType (testClass, sizeof(test), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS);
engine->RegisterObjectMethod (testClass, "Test opAssign(Test)", asMETHOD(test,copy), asCALL_THISCALL);
CScriptBuilder builder;
builder.StartNewModule(engine, "testModule");
builder.AddSectionFromFile("scripts/t.as");
builder.BuildModule();
asIScriptModule* module = engine->GetModule("testModule");
asIScriptFunction* func = module->GetFunctionByDecl("void testFunc()");
asIScriptContext* context = engine->CreateContext();
std::cout << "Prepare" << std::endl;
context->Prepare(func);
std::cout << "Execute" << std::endl;
context->Execute();
std::cout << "Done" << std::endl;
return (0);
}
And the AngelScript code :void testFunc()
{
Test test;
Test test2;
test = test2;
}
It crahses at the line "test = test".Can you please help me


















