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

bernd.edlinger at hotmail dot de gcc-bugzilla@gcc.gnu.org
Sat Jul 16 07:51:00 GMT 2016


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

--- Comment #7 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 38915
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38915&action=edit
possible patch

This is an attempt of a fix.

Not really perfect, but should be at least safe.

Only ECF_RETURN_TWICE is considered to be safe in general.

Except for possible Wclobber warnings, and bad optimization
of course, if for instance "getcontext" does not do what
we think it does.

If a built-in is defined, it can add the ECF_LEAF and/or
ECF_NORETURN, but only if no -ansi or -ffreestanding is
in effect.

I think the special handling of "setjmp_syscall",
"savectx", and "qsetjmp", as well as the prefix
"__x" are there since r201, and can be removed now.


More information about the Gcc-bugs mailing list