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

            Bug ID: 71876
           Summary: longjmp is miscompiled with -ffreestanding
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de
  Target Milestone: ---

Even with -ffreestanding we handle some functions conservatively.
See special_function_p.

However, the function longjmp and siglongjmp are not handled conservatively
as the following test case illustrates:

cat test.c
int longjmp(void);

int bar(void)
{
  return longjmp();
}

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

emits no warning, but resulting code is invalid (no ret):

bar:
.LFB0:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        call    longjmp
        .cfi_endproc

Reply via email to