On 4/29/24 23:29, Andrius Štikonas wrote:
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;
}

I pushed a fix for this on mob.

    Herman


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to