Article may be outdated

This article is 51 days old. Some details may have changed since publication.

Hacker News·3 min read·hard

Tail-call optimization in C is relatively recent

P
prakashqwerty
Tail-call optimization in C is relatively recent
✦AI Summary

A technical discussion regarding the history and implementation of tail-call optimization (TCO) in C compilers. The author notes that while TCO was historically limited in C, modern compilers like GCC and Clang have improved support for it.

Why it matters

Understanding compiler optimizations is critical for systems programming and performance-sensitive software development.

✦Dive DeeperCreate a free account to unlock

Tail-call optimization in C is relatively recent [LWN.net]

Tail-call optimization in C is relatively recent

Posted Aug 21, 2025 22:11 UTC (Thu) by anton (subscriber, #25547)

Parent article: Python, tail calls, and performance

Actually tail calls in C have not been around forever. The C calling convention has been that the callee does not remove any stuff the caller has put on the stack. The caller could see the declaration int f(); , the actual call could have n>0 arguments, and the actual function could have m n parameters. That would not always work if the callee removed the arguments.

So the caller had to remove the arguments between the call and the following return, turning the call into a non-tail call.

Continue reading on Headlinne

Create a free account to read the full article.

Read full article →
technologyscience
✦

Get smarter about the news

Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.

Create free account

Already have an account? Sign in