Hi, When trying to compile gcc, we stumbled upon strange segfault that seem to be coming from tcc.
This is the reproducer: struct thing { unsigned index; char mem[1]; }; struct function { struct thing* t; }; static inline struct thing* obtain (const struct function *f) { return f->t; } int main () { char *ptr; struct thing u = {.index = 0, .mem = {'a'}}; struct function g = {.t = &u}; struct function *f = &g; ptr = &(obtain(f)->mem[obtain(f)->index]); return *ptr; } When tcc (mob) is used to build it we get a segfault. On the other hand, GCC returns 97 ('a'). Some curious observation. Replacing the ptr line with struct thing * x = obtain(f); ptr = &(x->mem[x->index]); or with int x = obtain(f)->index; ptr = &(obtain(f)->mem[x]); Seems to workaround the crash on tcc-riscv64 but not on tcc-amd64. Kind regards, Andrius _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel