https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585

--- Comment #19 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Manually minimized testcase for investigation, miscompiled at -O2:

struct P {
        long v;
        struct P *n;
};

struct F {
        long x;
        struct P fam[];
};

int f(struct F *f, int i)
{
        struct P *p = f->fam;
        asm("" : "+r"(f): "r"(p));
        p->v = 0;
        p->n = 0;
        return f->fam->n != 0;
}

Trunk emits:
f:
        lea     rdx, [rdi+8]
        mov     rax, rdi
        mov     QWORD PTR [rdi+8], 0
        cmp     QWORD PTR [rax+16], 0
        mov     QWORD PTR [rdi+16], 0
        setne   al
        movzx   eax, al
        ret

Reply via email to