me: i wish we could have tail calls in c
gcc: we have tail calls at home
the tail calls:

https://godbolt.org/z/GT5PvnxP9

a kind person shares this powerful incantation: `if (1) [[gnu::musttail]]` https://godbolt.org/z/f8fzf9b5M
Compiler Explorer - C (x86-64 gcc 15.2)

int f(void); static int g(void) { return f(); return 11; } static int h(void) { if (1) [[gnu::musttail]] return f(); return 42; }

lol gcc's tail call implementation is extraordinarily squirrely, it happily inlines functions that do tail calls but then dies because it fails to turn the inlined tail calls into regular calls. (clang fails in different ways :P)
"cannot tail-call: other reasons" this energy is sending meeeeee, the compiler has determined that it is friday
@wingo I see why you liked the if (1)… Good luck with the tail calls.
@void_friend fwiw, i got it to work if i __attribute__((noinline)) the functions that make tail calls 😅
@wingo Why doesn't enabling the tail-call optimization for the entire compilation unit work for you? You're already targeting a GCC-like compiler anyway, surely you're compiling the C file yourself or can tell the person who will compile it to use -foptimize-sibling-calls (I think the option is)?
@wingo Also, I wonder if you could implement tail calls in standard C from longjmp (pls do not implement tail calls from longjmp)