[Bug middle-end/125874] gcc is incompatible with clang when using musttail and setjmp

mikpelinux at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jun 18 09:09:55 GMT 2026


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

--- Comment #3 from Mikael Pettersson <mikpelinux at gmail dot com> ---
I think this is invalid code. A tail-call deliberately discards the current
stack frame (aka "continuation") restoring the previous one, but the setjmp
records a reference to it in global scope. That is, you have a dangling pointer
and any longjmp would be UB.

The obvious fix while keeping the tail-calls is to put the setjmp in the
(non-tail) caller of c.


More information about the Gcc-bugs mailing list