Re: Minimum Stack Size
Adriaan van Os <[email protected]>
| Newsgroups | gmane.comp.compilers.gpc |
|---|---|
| Message-ID | <[email protected]> |
Kevan Hashemi wrote: > If you have a minute, please consider the following: > > procedure recursive(i:integer); > begin > if i<2000 then recursive(i+1); > end; Please post a complete test program with instructions to reproduce the problem. Doing so will also help you solve problem yourself. [p18:~/gpc/testgpc/adriaan] adriaan% cat teststack.pas program teststack; procedure recursive(i:integer); begin if i<2000 then recursive(i+1); end; begin recursive( 1) end. [p18:~/gpc/testgpc/adriaan] adriaan% gp teststack.pas -Wl,-stack_size,10000 [p18:~/gpc/testgpc/adriaan] adriaan% ./teststack Segmentation fault [p18:~/gpc/testgpc/adriaan] adriaan% gp teststack.pas -Wl,-stack_size,20000 [p18:~/gpc/testgpc/adriaan] adriaan% ./teststack In other words, stack usage is not excessive. Jay Michael wrote > If your procedure has local variables, that increases the size of its stack frame. > If your procedure has an argument that is a structure or array that is being passed by value, the compiler will be making a copy in the stack frame of the current invocation before calling the next level. Yes, that's the probable cause of the stack overflow. Excessive stack usage is often a sign of misdesigned code. Regards, Adriaan van Os _______________________________________________ Gpc mailing list [email protected] https://www.g-n-u.de/mailman/listinfo/gpc