https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64242
Bug ID: 64242 Summary: Longjmp expansion incorrect on i386 Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: wdijkstr at arm dot com As PR rtl-optimization/64151 showed, the longjmp expansion on i386 is incorrect if the base register is spilled. It turns out it is trivial to write an example that reproduces this without my patch: void broken_longjmp(int x, void *buf[20]) { if (x == 0) return; __builtin_longjmp (buf, 1); } With -O2 this produces: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax testl %eax, %eax jne .L5 leave ret .L5: movl 12(%ebp), %eax movl 4(%eax), %eax movl 12(%ebp), %edx movl (%edx), %ebp *** load new ebp movl 12(%ebp), %ecx *** try to use old ebp movl 8(%ecx), %esp jmp *%eax