Copy constructors appear to be broken

Started by
4 comments, last by WitchLord 2 months, 1 week ago

The latest SVN revision with the copy constructor changes seems to have broken some my vector bindings (which were working fine before).

class Foo {
	Foo() {}
	//Foo(int x) {} // Uncomment this to fix the problem

	vec2 v;
}

Foo LerpTest() {
	Foo p;
	p.v = vec2(1, 2);
	return p;
}

void Main() {
	print(LerpTest().v); // <-7.48036e-16, 7.91734e-43>
}

The above example will print out broken values in the vector, unless there is another constructor with 1 parameter. If you uncomment the second Foo constructor it will fix the problem, but if you add another parameter to the constructor, it's broken again.

The vec2 copy constructor has a declaration of void f(const vec2 &in) and a behavior of asBEHAVE_CONSTRUCT.

Are my vector bindings wrong after all, or is it a bug in the new default copy constructor changes?

Advertisement

It appears to be another bug with the new auto generated copy constructor.

(I'm starting to feel I made the wrong decision to implement that in the first place :( )

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

I've added the option to turn off the generation of copy constructors for backwards compatibility. You may want to use that while I investigate and fix the bugs:

https://sourceforge.net/p/angelscript/code/2895/

engine→SetEngineProperty(asEP_ALWAYS_IMPLEMENT_DEFAULT_COPY_CONSTRUCT, 2); // 0 = as per language spec, 1 = always, 2 = never

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

Thank you! I will use that setting for now. 👍

I've fixed this bug now. This was quite easy, the scenario was with registered value types with AS_POD that are allocated in memory in the script classes.

https://sourceforge.net/p/angelscript/code/2896/

Now back to the other bug.

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