"Recursion, need more stack space."

Mon, 16 Jun 1997 00:00:32 +0200



First the good news: in c.l.p.b (the same subject as this mail), someone
wrote:

"Anyway, I found this book in the library called "Programming Languages"
by Herbert G.Mayor.
In the book it has a program written in Algol-60 by Donald Knuth, which
is highly recursive etc.etc, and it was written to separate the 'boy
compilers' from the 'man compilers'.
The book states, that modern computers are able to run the program with
ease."

Guess what: the program compiled and ran fine with gpc, but couldn't
possibly compile with BP. :-)

(It relies on nested stack frames handled correctly with procedural
parameters. BP can't do this, but gpc does -- it's not trivial, and
it took me some time to understand the asm code generated by gpc... :-)

Now the bad news (not really so bad):

I then modified the program to compile with BP (quite extensive
modifications). The resulting program did not compile with gpc any
more. I could trace it down to the following bug (which is actually
not related to the problem that the program deals with). gpc doesn't
compile the following which is legal in BP (gpc says: "wrong type"
in the Writeln):

program p;

var x:record
        f:function:real;
      end;

begin
  Writeln(x.f)
end.

Another little bug I just found:

program x;
var x:real value 0; {"initial value is of wrong type}
begin
end.

(Also in other places, automatic integer->real conversion would be nice.)

Another thing I observed when looking at the asm code (see above) was
that the i386 backend doesn't seem to know the "push mem" instruction.
E.g., the program

program x;
var a:integer value 2;
begin
 writeln(a)
end.

compiled to asm code for i386-linux, contains the lines

	movl A.2,%eax
	pushl %eax

where actually

	pushl A.2

is possible (I tried it, and it worked). But since it's a backend problem
(the same can happen with gcc), this is probably the wrong place to
report it...
-- 
Frank Heckenbach, Erlangen, Germany
heckenb@mi.uni-erlangen.de
Turbo Pascal:   http://www.mi.uni-erlangen.de/~heckenb/programs.htm
Internet links: http://www.mi.uni-erlangen.de/~heckenb/links.htm


Frank Heckenbach (heckenb@mi.uni-erlangen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es