by Player701 » Thu Sep 30, 2021 1:14 am
Here's some additional information about this issue that might be useful in resolving it:
- It doesn't have to do anything with abstract functions (replacing abstract with virtual and adding an empty body does not change the behavior).
- It has something to do with structs.
- In particular, it has something to do with structs that have other structs as members.
- It also has something to do with the order in which the structs are defined (moving the definition of MyInnerStruct to before MyStruct resolves the crash).
- The crash itself appears to be a side-effect of memory corruption (crashes somewhere in the FString code, complaining about invalid pointers).
- The crash might have something to do with inheritance, or it could be just a more efficent way of triggering it (merging the classes Base and Derived, in this case, resolves the crash).
I first encountered this issue while rewriting the UI code in my project to use structs (to work around
this bug, as it seems that it's not going to get fixed in the foreseeable future), and then had quite a difficult time attempting to isolate it. Aside from this particular issue, user-defined structs in ZScript do seem to suffer from several other drawbacks, and are thus not suitable for production use yet (IMHO).
Here's some additional information about this issue that might be useful in resolving it:
[list=1][*]It doesn't have to do anything with abstract functions (replacing [c]abstract[/c] with [c]virtual[/c] and adding an empty body does not change the behavior).
[*]It has something to do with structs.
[*]In particular, it has something to do with structs that have other structs as members.
[*]It also has something to do with the order in which the structs are defined (moving the definition of [c]MyInnerStruct[/c] to before [c]MyStruct[/c] resolves the crash).
[*]The crash itself appears to be a side-effect of memory corruption (crashes somewhere in the [c]FString[/c] code, complaining about invalid pointers).
[*]The crash [i]might[/i] have something to do with inheritance, or it could be just a more efficent way of triggering it (merging the classes [c]Base[/c] and [c]Derived[/c], in this case, resolves the crash).[/list]
I first encountered this issue while rewriting the UI code in my project to use structs (to work around [url=https://forum.zdoom.org/viewtopic.php?f=2&t=70492]this bug[/url], as it seems that it's not going to get fixed in the foreseeable future), and then had quite a difficult time attempting to isolate it. Aside from this particular issue, user-defined structs in ZScript do seem to suffer from several other drawbacks, and are thus not suitable for production use yet (IMHO).