AFAIK most compiler will do tail-recursion optimization if the method ends in a tail call to the current function (obviously) or to a &quot;sibling&quot; function (i.e. if a() calls b() which calls a() again and so on) and is sufficiently short to be suitable for inlining.<p>It&#x27;s important to remember local objects with destructors will make this impossible, since destructors are run at the end of the function scope and thus after what&#x27;s seemingly a perfect tail call.