modernc.org/ccgo/v3@v3.16.14/lib/testdata/bug/sqlite.c (about) 1 struct item { 2 char *zColl; 3 }; 4 5 struct item item = {"foo"}; 6 7 void f1(struct item item) { 8 __builtin_printf("%i: %s\n", __LINE__, item.zColl); 9 } 10 11 void f2(struct item *item) { 12 __builtin_printf("%i: %s\n", __LINE__, item->zColl); 13 } 14 15 struct tab { 16 struct item aCol[3]; 17 }; 18 19 struct tab tab = {{{"foo"}, {"bar"}, {"baz"}}}; 20 21 int j = 1; 22 23 void f3(struct tab tab) { 24 __builtin_printf("%i: tab.aCol[j].zColl %s\n", __LINE__, tab.aCol[j].zColl); 25 } 26 27 void f4(struct tab *ptab) { 28 __builtin_printf("%i: ptab->aCol[j].zColl %s\n", __LINE__, ptab->aCol[j].zColl); 29 } 30 31 struct y { 32 struct tab *ptab; 33 }; 34 35 struct y y = {&tab}; 36 37 void f5(struct y y) { 38 __builtin_printf("%i: y.ptab->aCol[j].zColl %s\n", __LINE__, y.ptab->aCol[j].zColl); 39 } 40 41 void f6(struct y *y) { 42 __builtin_printf("%i: y->ptab->aCol[j].zColl %s\n", __LINE__, y->ptab->aCol[j].zColl); 43 } 44 45 struct p { 46 struct y y; 47 }; 48 49 struct p p; 50 51 void f7(struct p p) { 52 __builtin_printf("%i: p.y.ptab->aCol[j].zColl %s\n", __LINE__, p.y.ptab->aCol[j].zColl); 53 } 54 55 void f8(struct p *p) { 56 __builtin_printf("%i: p->y.ptab->aCol[j].zColl %s\n", __LINE__, p->y.ptab->aCol[j].zColl); 57 } 58 59 // const char *zColl = p->y.pTab->aCol[j].zColl; 60 61 int main() { 62 p.y = y; 63 f1(item); 64 f2(&item); 65 f3(tab); 66 f4(&tab); 67 f5(y); 68 f6(&y); 69 f7(p); 70 f8(&p); 71 }