Re: Proper Tail Recursive C++

njl@cyberpass.net (Nathan Loofbourrow)
21 Mar 1997 10:23:02 -0500

          From comp.compilers

Related articles
[10 earlier articles]
Re: Proper Tail Recursive C++ njl@cyberpass.net (1997-03-09)
Re: Proper Tail Recursive C++ hbaker@netcom.com (1997-03-13)
Re: Proper Tail Recursive C++ fjh@murlibobo.cs.mu.OZ.AU (1997-03-13)
Linking Was: Re: Proper Tail Recursive C++ hrubin@stat.purdue.edu (1997-03-16)
Re: Proper Tail Recursive C++ ramsdell@linus.mitre.org (1997-03-16)
Re: Proper Tail Recursive C++ danwang@atomic.CS.Princeton.EDU (1997-03-18)
Re: Proper Tail Recursive C++ njl@cyberpass.net (1997-03-21)
Re: Proper Tail Recursive C++ erik.schnetter@student.uni-tuebingen.de (1997-03-21)
| List of all articles for this month |
From: njl@cyberpass.net (Nathan Loofbourrow)
Newsgroups: comp.compilers
Date: 21 Mar 1997 10:23:02 -0500
Organization: Infonex Internet Services
References: 97-02-111 97-02-141 97-03-042 97-03-050 97-03-074
Keywords: C++, optimize

Fergus Henderson <fjh@murlibobo.cs.mu.OZ.AU> wrote:
  > I'm sure the reason that it crashes is not that g++ generates
  > incorrect code, but rather that it just runs out of stack space.
  > (William Clinger's code had the above function recursively invoking
  > itself a million times.)


Oops, you're right, a look at the assembled code confirms this. The
tail recursion is inhibited by the presence of the automatic array
variable(!). This can be confirmed by removing all reference to the
array; the tail recursion optimization still does not occur until it
is removed completely.


nathan
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.