Advertisement

Passing getter result to function registered with inout parameter

Started by August 23, 2011 01:19 PM
2 comments, last by WitchLord 13 years, 3 months ago

class Foo
{
string s;
Foo(const string& s)
{
this.s = s;
}
string get_Str() const
{
return s;
}
}

Foo f("test");
Log(f.Str); // garbage output
Log(f.get_Str()); // correct output


Log is just:

void Log(const string& s)
{
printf("Log: %s\n", s.c_str());
}


When registered as: "void Log(const string&in)" it's fine. When registered as "void Log(const string&inout)" it crashes, or yields strange results. Having parameter specified as const reference or normal reference doesn't change anything.

Tested on r838(our environment) and r941 (test_getset.cpp):
http://pastebin.com/m1F67qy5


I'm not sure what's the difference between calling getter directly (as function, then it returns temporary object we then pass to our function) as opposed to passing it using property syntax. What exactly going on there?

It's definitely a bug in AngelScript. I'll look into it.

Are you using the CScriptString add-on? Or the CScriptStdString with asEP_ALLOW_UNSAFE_REFERENCES?

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

Advertisement
CScriptString
I've fixed this bug in revision 944.



Thanks,

Andreas

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