[Bug c/71538] Obvious optimization related to arrays aren't performed.
sasho648 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 15 17:13:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71538
--- Comment #4 from sasho648 at gmail dot com ---
More *shocking* example will be:
struct tx { int a[6], b[6]; } *f();
void (main)()
{
int *p = f()->b;
if(p == NULL)
printf("What?");
}
Compiling with "gcc -Ofast -c test.c -o a.out" will result in this assembly
output:
;main function
sub rsp, 8
xor eax, eax
call f
cmp rax, 0FFFFFFFFFFFFFFE8h
jz short loc_26
loc_21:
add rsp, 8
retn
; ---------------------------------------------------------------------------
loc_26:
pop rdx
mov edi, offset format ; "What?"
xor eax, eax
loc_2E:
jmp printf
;main function end
Keeping the printf branch which at least for me is amazing.
More information about the Gcc-bugs
mailing list