Compiling this code with -O2 -S struct s { int a; int b;}; void bar (struct s *ps, int *p, int *__restrict__ rp, int *__restrict__ rq) { ps->a = 0; ps->b = 1; if (ps->a != 0) abort (); p[0] = 0; p[1] = 1; if (p[0] != 0) abort (); rp[0] = 0; rq[0] = 1; if (rp[0] != 0) abort(); } should eliminate all the "abort" calls. and it does happen with: GCC: (GNU) 4.1.1 20060525 (Red Hat 4.1.1-1) but GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-51) generates: .file "t.c" .text .p2align 4,,15 .globl bar .type bar, @function bar: pushl %ebp movl %esp, %ebp subl $8, %esp movl 8(%ebp), %eax movl 12(%ebp), %edx movl 16(%ebp), %ecx movl $0, (%eax) movl $1, 4(%eax) movl (%eax), %eax testl %eax, %eax jne .L10 movl $0, (%edx) movl $1, 4(%edx) movl (%edx), %edx testl %edx, %edx jne .L10 movl 20(%ebp), %eax movl $0, (%ecx) movl $1, (%eax) movl (%ecx), %eax testl %eax, %eax jne .L10 leave ret .L10: call abort .size bar, .-bar .ident "GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-51)" This is PR30643 for gcc mainline. It seems that it somehow got backported to 4.1.1-51.
This isn't Fedora gcc specific problem, tracking it just upstream is enough, when it is fixed there it will show up in Fedora gcc very soon.
Created attachment 149557 [details] Patch that fixes the bug in 4.1 Trunk needs more than this, but this patch fixes the bug in 4.1.
Should be fixed in gcc-4.1.2-4 in rawhide.