# bug with ?& and ?&out

## Recommended Posts

Hi!

if we are register functions as "bool retrieve(?&out)" this logic work fine:

AS:
SomeScriptObject @obj_null;
retrieve( obj_null );

c++:
bool retrieve( void *ptr, int type_id ){
ptr != 0x000000; // ok
}

And them, if we are use without out - "bool retrieve(?&)" in c++ handle will be always 0x000000.

AS:
SomeScriptObject @obj_null;
retrieve( obj_null );

c++:
bool retrieve( void *ptr, int type_id ){
ptr == 0x000000; // always
}

use unsafe refences == true!

##### Share on other sites

Thanks. I'll look into this.

##### Share on other sites

Sorry for taking so long in looking into this.

Actually, both examples that you gave above are correct. What happens is that in the first case AngelScript will create dummy instance of SomeScriptObject and pass the reference to that object to the function so that the function can assign the output value in it. This is why the reference is always pointing to a valid object. In the second case AngelScript will always send the reference to the true object, which in this case is null.

There was a bug however related to var args and unsafe references, and that was in this scenario:

AS:
SomeScriptObject @obj_null;
retrieve( @obj_null );

c++:
bool retrieve( void *ptr, int type_id ){
ptr == 0x000000; // not ok. should be a reference to the handle
}


In this case AngelScript was supposed to pass the reference to the handle (since it was explicitly told so with @), but it was passing the reference to the object instead, which in this case would be null.

I've fixed this problem in revision 1726.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628382
• Total Posts
2982367

• 10
• 9
• 15
• 24
• 11