The following code will cause a null exception in the else
block in the Foo
constructor.
class Bar {
int m_value;
Bar(int value) { m_value = value; }
}
class Foo {
Bar m_bar;
Foo(bool b) {
if (b) m_bar = Bar(1);
else m_bar = Bar(2);
}
}
Foo g_foo(false);
The following produces similar results:
class Bar {
int m_value;
Bar(int value) { m_value = value; }
}
class Foobase {
Bar m_a;
Bar m_b;
Foobase(bool b) {
m_a = Bar(1);
if (b) return;
m_b = Bar(2);
}
}
class Foo : Foobase {
Foo() {
super(true);
m_b = Bar(3);
}
}
Foo g_foo;
I assume this is related to this change:
- Added engine property asEP_MEMBER_INIT_MODE to allow backwards compatiblity for how class members are initialized
- A class member can now be explicitly initialized in the class constructor, overriding the initialization defined in the declaration
I really like this change, but I feel like the behavior described above is probably a bug?