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.

Reply via email to