tail recursion

Wilhelm B. Kloke wb@yorikke.arb-phys.uni-dortmund.de
Wed Nov 3 07:34:00 GMT 1999


Hi,

I found that in the following simple program tail recursion is not recognized:

/* this silly program just tries to use recursion for one of
   the simplest types of iterations */
void For(int start, int end, void what(int) ) {
what(start);
if(start <= end) For(start, end, what);
}
void printi(int i) { printf( "%d\n", i ); }
void main(){ For(0,15,printi); }

on FreeBSD/i386 with egcs-1.1.2 release and gcc-2.7.2.1.

As C is often used as output language of program generators, this
could be considereda as a nearly-bug.

--

I have a 2nd problem not related to this (but also coming from
machine generated programs). I have a colleague who tries to solve
large systems of differential equations using a package outputting
FORTRAN. Some of the modules choke either g77 or gcc (when f2c was
used) by just having a real long sequence of simple assignments
to elements of matrices, sometimes even with optimization disabled.

Here is an example line (FORTRAN):
      AMAT(495) = SUB(7128)*SUB(333)+SUB(7117)*SUB(354)+SUB(7129)
     &*SUB(349)+SUB(7130)*SUB(333)+SUB(7116)*SUB(354)+SUB(7131)*SUB(349)
     &+SUB(7132)*SUB(333)+SUB(7115)*SUB(354)+SUB(7133)*SUB(349)
     &+SUB(7134)*SUB(333)+SUB(7114)*SUB(354)+SUB(7135)*SUB(349)
     &+SUB(7136)*SUB(333)+SUB(7113)*SUB(354)+SUB(7137)*SUB(349)
     &+SUB(7138)*SUB(333)+SUB(7112)*SUB(354)+SUB(7139)*SUB(349)
     &+SUB(7140)*SUB(333)+SUB(7111)*SUB(354)+SUB(7141)*SUB(349)
     &+SUB(7142)*SUB(333)+SUB(7110)*SUB(354)+SUB(7143)*SUB(349)
     &+SUB(7144)*SUB(333)+SUB(7109)*SUB(354)+SUB(7145)*SUB(349)
     &+SUB(7146)*SUB(333)+SUB(7107)*SUB(354)+SUB(7147)*SUB(349)
     &+SUB(7148)*SUB(333)+SUB(7108)*SUB(354)+SUB(7149)*SUB(349)
     &+SUB(7208)

There seem to be more then 15000 lines of such code.

Perhaps this bug (LCC does compile the stuff, e.g.) indicates
a general problem with memory management inside gcc.

If you are interested in more details, please ask.

Thanks in advance. wbk
-- 
Dipl.-Math. Wilhelm Bernhard Kloke
Institut fuer Arbeitsphysiologie an der Universitaet Dortmund
Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-257 mittwochs und donnerstags


More information about the Gcc-bugs mailing list