Closed
Description
Consider the following code:
#include <stdio.h>
#include <tice.h>
typedef struct {
int a;
} Inner;
typedef struct {
int i1;
int i2;
} TestStruct;
void use(TestStruct ts) {
printf("%d\n", ts.i2);
}
Inner test(TestStruct ts) {
printf("%d\n", ts.i2);
use(ts);
Inner i = {0};
return i;
}
void waitForKey() {
uint16_t key;
do {
key = os_GetKey();
} while (key != sk_Enter);
}
int main(void) {
TestStruct ts = {1,2};
printf("%d\n", ts.i2);
test(ts);
waitForKey();
return 0;
}
It produces the output
2
1
1
It should instead produce the output
2
2
2
The first element of ts.i1
is printed instead of ts.i2
in test
and use
.
Here is full project that reproduces this issue: TestWeirdThing.zip