tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Miscompiled code (when building GCC)


From: Herman ten Brugge
Subject: Re: [Tinycc-devel] Miscompiled code (when building GCC)
Date: Sat, 1 Jun 2024 07:42:42 +0200
User-agent: Mozilla Thunderbird

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]