🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50210

Tail-recursion in C with GCC

#50210
From: Yuli Zhou
Date: Wed, 13 Oct 1993 15:03
23 lines
1376 bytes
Hello,

I am experimenting with a CPS compiler which generates C code,
therefore I need some help to find out how to compile
tail-recursive C programs with GCC. This means that, if I have
a function

 foo { ... bar (args ...) ... }

and I don't want the call to bar to return, how do I tell
GCC to generate code sequence for a jump and transfer args ...
in registers.  In general, bar is not necessarily the same
as foo.
      
The GCC manual says that tail-recursion is recongnized early on
in the compiler, but I don't know how extensively GCC performs
tail-recursion optimization.  I also wonder if there is some kind
of annotation that can force GCC to compile a tail call whenever
I want to.

Thanks!

Yuli
Technical Details
Message-ID: <ZHOU.93Oct13150341@corvette.lcs.mit.edu>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!cs.utexas.edu!uunet!bloom-beacon.mit.edu!grapevine.lcs.mit.edu!news.lcs.mit.edu!zhou

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,b01bcd9af109917d,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-10-13 14:32:59 PST
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!cs.utexas.edu!uunet!bloom-beacon.mit.edu!grapevine.lcs.mit.edu!news.lcs.mit.edu!zhou
From: zhou@corvette.lcs.mit.edu (Yuli Zhou)
Newsgroups: gnu.gcc.help
Subject: Tail-recursion in C with GCC
Date: 13 Oct 93 15:03:41
Organization: MIT Lab for Computer Science
Lines: 23
Distribution: gnu
Message-ID: <ZHOU.93Oct13150341@corvette.lcs.mit.edu>
NNTP-Posting-Host: corvette.lcs.mit.edu