Closed Dragon-Hatcher closed 2 years ago
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.
ts.i1
ts.i2
test
use
Here is full project that reproduces this issue: TestWeirdThing.zip
Consider the following code:
It produces the output
It should instead produce the output
The first element of
ts.i1
is printed instead ofts.i2
intest
anduse
.Here is full project that reproduces this issue: TestWeirdThing.zip