[Bug middle-end/71876] longjmp is miscompiled with -ffreestanding

bernd.edlinger at hotmail dot de gcc-bugzilla@gcc.gnu.org
Thu Jul 14 14:18:00 GMT 2016


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

--- Comment #6 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Jakub Jelinek from comment #5)
> Perhaps ECF_MAY_BE_ALLOCA too?  But ECF_NORETURN and ECF_LEAF are not
> conservative, sure.

Yes. That's right.
alloca can not return null.
See tree_expr_nonzero_warnv_p.

Test case:

void *alloca(void);

void bar(void)
{
  char * x = alloca();
  if (x) 
    *x = 0;
}

gcc -Wall -O3 -S -ffreestanding test.c

result: if(x) is optimized away:

bar:
.LFB0:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        call    alloca
        movb    $0, (%rax)
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc


More information about the Gcc-bugs mailing list