Jump to content

[SOLVED] Call function behavior


photo

Recommended Posts

Hello !

 

Today I made some tests with "call" function.

 

Look at the code below (could be pasted in a new world for tests) :

 

void test(int a, int b, int c = 42)
{
  log.message("Called -- " + string(a) + " -- " + string(B) + " -- " + string(c) + "\n") ;
}

int init()
{
 test(12, 24, 48) ;
 test(12, 24) ;
 call("test", 12, 24, 48) ;
 call("test", 12, 24) ;

 return 1 ;
}

 

The result is :

- First three calls OK

- Last one crash

 

10:09:10 Called -- 12 -- 24 -- 48
10:09:10 Called -- 12 -- 24 -- 42
10:09:10 Called -- 12 -- 24 -- 48
10:09:10 Machine::do_callfd(): cant find "test" function with 2 arguments
10:09:10 Stack dump:
10:09:10 0x0000: int: 12
10:09:10 0x0001: int: 24
10:09:10 Call stack:
10:09:10 00: 0x00000026 init()
10:09:10 Disassemble:
10:09:10 0x0000004a: callfd 2
10:09:10 0x0000004d: pop
10:09:10 0x0000004e: pushc int: 1
10:09:10 0x00000050: ret
10:09:10 0x00000051: pushc int: 0
10:09:10 World::loadWorld(): world init function return 0 in "Airbus.cpp" file

 

It seems that the default argument value is not taken into account, is this the desired behavior or a bug ?

 

Thank you !

Link to comment
  • 2 weeks later...
×
×
  • Create New...