Structure initialization generates garbage values
Brought to you by:
acceptthis,
timeserv
This is compounded by nesting structures, but attempting to zero-fill with "v = (type) { }" generates garbage.
Here is an MVP:
struct nest_2
{
int eger;
float ing;
vector pos;
};
struct nest_1
{
nest_2 nested;
int x;
float y;
};
struct nest_0
{
nest_1 nested;
float x;
int y;
};
void() test =
{
nest_0 state;
state = (nest_0) { };
state.nested = (nest_1) { };
state.nested.nested = (nest_2) { };
};
The output is seemingly nonsensical:
For some reason it attempts to initialize the vector first; is this a result of the way the structure is laid out? I expected it to be C-like, where state.nested.nested.eger would be offset 0, but there definitely seems to be something up here. Generating the clears by hand generates better code, and is what I expected to come out of this operation:
Moved to https://github.com/fte-team/fteqw/issues/131