Open noresistence opened 5 years ago
I try to pass a struct (that contains an array) as a parameter to another function:
struct In { char alibi; }; struct Out { char alibi; }; typedef struct data { char name[1]; } data_t; void foo(data_t data) { char *x; x = data.name; } void compute(struct In *input, struct Out *output) { data_t test; foo(test); }
Trying to compile this example fails with the error: Address has not been assigned yet.
Address has not been assigned yet.
If i initialize the struct, the same error occurs. However, passing the struct by reference does not throw the error:
struct In { char alibi; }; struct Out { char alibi; }; typedef struct data { char name[1]; } data_t; void foo(data_t *data) { char *x; x = data->name; } void compute(struct In *input, struct Out *output) { data_t test; foo(&test); }
Trying to access something else in the struct that is not an array works as well, even when passed by value:
struct In { char alibi; }; struct Out { char alibi; }; typedef struct data { char name; } data_t; void foo(data_t data) { char x; x = data.name; } void compute(struct In *input, struct Out *output) { data_t test; foo(test); }
I suspect it is a bug that passing the struct by value and then accessing an array does not compile?
Thanks for reporting this! I was able to reproduce the error.
Indeed, it looks like a bug in the frontend of the compiler. I'll try to take a look at it more closely soon.
Any update on this?
I try to pass a struct (that contains an array) as a parameter to another function:
Trying to compile this example fails with the error:
Address has not been assigned yet.
If i initialize the struct, the same error occurs. However, passing the struct by reference does not throw the error:
Trying to access something else in the struct that is not an array works as well, even when passed by value:
I suspect it is a bug that passing the struct by value and then accessing an array does not compile?