Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Constructor with parameters assert


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 11 October 2004 - 09:56 PM

This is the code to reproduce (based on test_constructor.cpp 1.9.2) :
class CMyObj {
public :
	CMyObj() {};
	virtual ~CMyObj() {};
};

void ConstrMyObj(CMyObj &obj)
{
	new(&obj) CMyObj();
}

void DestrMyObj(CMyObj &obj)
{
	obj.~CMyObj();
}

class CMySecondObj {
	CMyObj *m_myObj;
public :
	CMySecondObj(CMyObj *in_myObj = NULL) {m_myObj = in_myObj;};
	virtual ~CMySecondObj()  {};
};

void ConstrMySecondObj(CMySecondObj &obj)
{
	new(&obj) CMySecondObj();
}

void ConstrMySecondObj(CMyObj &o, CMySecondObj &obj)
{
	new(&obj) CMySecondObj(&o);
}

void DestrMySecondObj(CMySecondObj &obj)
{
	obj.~CMySecondObj();
}

bool TestConstructor()
{
	bool fail = false;

	asIScriptEngine *engine;
	int r;
	engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);

	r = engine->RegisterObjectType("MyObj", sizeof(CMyObj), asOBJ_CLASS); assert( r >= 0 );
	r = engine->RegisterObjectBehaviour("MyObj", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstrMyObj), asCALL_CDECL_OBJLAST); assert( r >= 0 );
	r = engine->RegisterObjectBehaviour("MyObj", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestrMyObj), asCALL_CDECL_OBJLAST); assert( r >= 0 );

	r = engine->RegisterObjectType("MySecondObj", sizeof(CMySecondObj), asOBJ_CLASS); assert( r >= 0 );
	r = engine->RegisterObjectBehaviour("MySecondObj", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONP(ConstrMySecondObj, (CMySecondObj &)), asCALL_CDECL_OBJLAST);
	assert( r >= 0 );
	r = engine->RegisterObjectBehaviour("MySecondObj", asBEHAVE_CONSTRUCT, "void f(MyObj& in_myObj)", asFUNCTIONP(ConstrMySecondObj, (CMyObj &, CMySecondObj &)), asCALL_CDECL_OBJLAST);
	assert( r >= 0 );
	r = engine->RegisterObjectBehaviour("MySecondObj", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestrMySecondObj), asCALL_CDECL_OBJLAST); assert( r >= 0 );
	
	engine->ExecuteString(0, "MyObj obj; {MySecondObj secObj(obj);}");
	engine->Release();


	// Success
	return fail;
}





At ExecuteString you get an assert caused by as_bytecode.cpp at line 563 (
// Make sure we found a destructor
				assert( n < destructors.GetLength() );
because n = 1 and destructors.length = 1. Regards, AbrKen. Oops, I forgot to mention that ignoring the assert is ok, the program gently terminate. Oops 2, ignoring the assert only work with my big application !? [Edited by - abrken on October 12, 2004 4:46:33 AM]

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3241

Like
0Likes
Like

Posted 12 October 2004 - 03:27 AM

I'll look into this during the day.

I have plans to release a new WIP later today with a few bug fixes.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 12 October 2004 - 08:05 PM

1.9.2a solved the problem, thank's !

#4 Andreas Jonsson   Moderators   -  Reputation: 3241

Like
0Likes
Like

Posted 13 October 2004 - 02:00 AM

Thanks for confirming the fix.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS