Re: stack overflow at compile time



Henry Spencer wrote:
(snip on stack size bounds at compile time)

This is true, but uninteresting. :-) All real programs are special cases
of one kind or another, as witness the fact that human beings reason
effectively (if not always correctly) about their programs' halting
behavior all the time.

In the absence of recursion or non-trivial dynamic allocation, bounding
stack size at compile time is obviously a straightforward problem:
generate the call graph, label each arc with the stack size of the routine
being called, and find the greatest "distance" from the root to a leaf.
The maximum may occur on a path that's actually impossible, but at least
you do get a bound.

But it is difficult to tell at compile time which routines are actually
called, even though you may know there is no recursion and only fixed
sized allocation. You could, then, way overestimate the stack usage.

With recursion you could easily underestimate it, not knowing the
maximum recursion level.

-- glen

.



Relevant Pages

  • Re: FORTH: BEGIN as compile-time and no run-time?!?!?!?!? Help
    ... Variant recipes created by inexperienced cooks rarely make for ... >>lay destinations at compile time, ... > IF pushes its list address on the stack and will write down the BRANCH ...
    (comp.lang.asm.x86)
  • Re: passing arguments dynamically to functions
    ... You have to be careful which calling convention is ... must know at compile time how many arguments to pass and what type ... >arguments has to be the actual hardware stack, ...
    (comp.lang.cpp)
  • Re: FORTH levels
    ... at least for the number of arguments and stack errors. ... know the stack diagram of each word, they are able to track data type ... PICK, ROLL and FIND, whose stack effects are ambiguous at compile time, are ...
    (comp.lang.forth)
  • Re: stack overflow at compile time
    ... for all the locals/temporaries/function arguments so at compile time one ... can know the stack requirement of a particular function. ... that stack overflow will occur or not. ...
    (comp.compilers)
  • Re: Any use for recursion?
    ... In modern languages there is no overhead. ... popped back off the stack, the program counter being changed again. ... Recursion is ubiquitous in modern software. ...
    (comp.programming)