🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Strange code works normally.

Started by
4 comments, last by WitchLord 6 years, 2 months ago

Stopped at the following `ASSERT` and we investigated,


void asCByteCode::AddPath(asCArray<asCByteInstruction *> &paths, asCByteInstruction *instr, int stackSize)
{
    if( instr->marked )
    {
        // Verify the size of the stack
        asASSERT(instr->stackSize == stackSize);

Eventually, It was caused by the following.


class A
{
};
class B
{
  B() { print("B\n"); }
};

int main()
{
  A a;
  a.B();
  return 0;
}

When preparing the above code and executing it,

$ ./asrun.exe script2.as
B

It was due to normal compilation passing and normal operation.

ps,
I was surprised that someone wrote such code.
Also, thank you very much for your support. I am grateful to you.

 

 

Advertisement

Thanks for the report.

This code really should be giving a compiler error.

I'll investigate and have it fixed.

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

as_compiler.cpp

line 10679


// If at this point no functions have been identified, then this may be a construct call
if (funcs.GetLength() == 0)
{
	bool isValid = false;
	asCDataType dt = builder->CreateDataTypeFromNode(node->firstChild, script, outFunc->nameSpace, false, 0, false, &isValid);
	if (isValid)
		return CompileConstructCall(node, ctx);
}

change the line

if(funcs.GetLength()==0)

to 

if (funcs.GetLength() == 0 && objectType == 0)

may solve the problem, hope this will help :)

Wow, nice find. That's quite some funky code!

glcolor's solution is correct.

I've fixed this in revision 2487.

 

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

This topic is closed to new replies.

Advertisement