Consider the following code:
class int_holder{
int value;
int_holder(int x){value=x;}}
int_holder sink(2);
int test_1(int_holder @a = sink){a.value++;return a.value;}
int test_2(){return test_1();}
int b = test_2();
This fails with the error:
ANGELSCRIPT: ERR : Failed to initialize global variable 'b'
ANGELSCRIPT: INFO : Exception 'Null pointer access' in 'int test_2()
I suspect the code fails because the initialization for b
is run before sink
is initialized. I can make it work as intended with either int b = test1()
or int b = int_holder(test_2()).value;
. This seems to run test_2()
after sink
was initialized, thus no bug occurs.
Default values can't combine with delayed function calls unless the initialization would be more lenient somehow (a lazy suggestion would be that if Null pointer access
errors "would occur" run another initialization pass and see if any of them are resolved. If none of them are resolved, then fail with said error.)