Re:Tail-call optimization in C is relatively recent
by pjmlp on Monday August 10, 2026 @09:19AM
(#49243260)
It still doesn't, this is a compiler specific language extension.
You won't find anything on ISO/IEC 9899:2024 about tail calls, like it happens on Scheme.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
Section 3.5 of R7RS.
Re:Tail-call optimization in C is relatively recent
by kenjin4096 on Monday August 10, 2026 @11:54AM
(#49245353)
Woops, I meant to write tail call optimization not tail calls. Shouldn't have used the term interchangeably. Yeah I'm aware that C doesn't have proper tail calls. Thanks for the correction though.
Re:Tail-call optimization in C is relatively recent
by wahern on Monday August 10, 2026 @09:46AM
(#49243605)
A formal technical specification (TS) extension is already being drafted: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3582.pdf That's a step up from the usual proposals. I'm not sure what criteria is used to decide whether to first create a TS vs just incorporating a change into the working draft of the next standard.[1] _Defer also seems to be taking the TS route.[2]
1. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3886.pdf
2. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3928.pdf
Re:Tail-call optimization in C is relatively recent
by leoc on Monday August 10, 2026 @10:10AM
(#49243932)
There's some discussion of how C29 defer ended up in a TS at https://thephd.dev/c2y-the-defer-technical-specification-its... .
Re:Tail-call optimization in C is relatively recent
by pjmlp on Monday August 10, 2026 @09:57AM
(#49243738)
Well, even if that lands on the official standard, that means C29 as probable release year for C2y, plus adoption of the exact form across compilers to be able to rely on it being available.
Re:Tail-call optimization in C is relatively recent
by Someone on Monday August 10, 2026 @10:11AM
(#49243953)
Plus the fact that an implementation that recognizes the new syntax and produces an error whenever it encounters it will be conforming.
On such an implementation, the feature is available but useless.
Re:Tail-call optimization in C is relatively recent
by cryptonector on Monday August 10, 2026 @07:53PM
(#49251474)
I think Anton is wrong. Since C89 and before C23 calling an `int f();` function with arguments not matching the definition's actuals is UB. In C23 `int f();` became the same as `int f(void);`, so calling that function with any arguments is a compile-time error.
For variadic functions, if you use `va_start()`/`va_arg()`/`va_end()` to consume all the arguments, and leave no `va_list` alive, then the compiler can correctly generate a tail call from such functions.
On the other hand, I am pretty new to the compiler space myself, and I count early 2000s as a pretty long time ago, though again it is not that far back considering how long other language implementations had tail calls like in ML or variants since 1980-90s.