[Bug c/71876] longjmp is miscompiled with -ffreestanding
bernd.edlinger at hotmail dot de
gcc-bugzilla@gcc.gnu.org
Thu Jul 14 12:19:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71876
--- Comment #2 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
test case for the ECF_LEAF:
test.c:
int setjmp(void);
static int x;
void foo(int z)
{
x = z;
}
int bar(void)
{
int z = x;
setjmp();
z += x;
return z;
}
gcc -O3 -S -ffreestanding test.c
bar:
.LFB1:
.cfi_startproc
subq $24, %rsp
.cfi_def_cfa_offset 32
movl x(%rip), %eax
movl %eax, 12(%rsp)
call setjmp
movl 12(%rsp), %eax
addq $24, %rsp
.cfi_def_cfa_offset 8
addl %eax, %eax
ret
.cfi_endproc
but the free-standing setjmp function could call back to foo.
More information about the Gcc-bugs
mailing list