|stack overflow at compile time firstname.lastname@example.org (Jatin Bhateja) (2006-04-27)|
|Re: stack overflow at compile time NOSPAMrszeflerNOSPAM@murator.com.pl (RobertSzefler) (2006-04-27)|
|Re: stack overflow at compile time email@example.com (Volker Barthelmann) (2006-04-27)|
|Re: stack overflow at compile time nitin@CoWare.com (Nitin Gupta) (2006-04-27)|
|Re: stack overflow at compile time firstname.lastname@example.org (2006-04-27)|
|Re: stack overflow at compile time email@example.com (glen herrmannsfeldt) (2006-04-28)|
|Re: stack overflow at compile time firstname.lastname@example.org (=?ISO-8859-1?Q?Jan_Vorbr=FCggen?=) (2006-04-28)|
|[8 later articles]|
|From:||"Jatin Bhateja" <email@example.com>|
|Date:||27 Apr 2006 09:14:54 -0400|
|Keywords:||storage, theory, comment|
|Posted-Date:||27 Apr 2006 09:14:54 EDT|
Is it possible at compile time to know whether there is a possibility of
stack overflow at run time? I feel that to some extent it is possible.
Let me explain it to you in detail. As compiler knows the stack offsets
for all the locals/temporaries/function arguments so at compile time one
can know the stack requirement of a particular function.
Now problem will occur in case of recursive function where if the
condition of recursion is not calculable at compile time then one cannot
make out the stack requirements.
Another thing is that as the size of executable comprises code and
global data it contains (of course not uninitialized global data) and at
run time heap and stack space is allocated to the running executable. So
if our OS is single tasking then only one program is present in memory
at run time and so the maximum size of stack that can be used is size of
the entire virtual memory. Thus under this circumstances if one knows
the stack size requirement of a program then we can tell at compile time
that stack overflow will occur or not.
Also this decision will be taken by the linker (of course it will use
some extra info about the stack requirement of a program that will be
emitted by compiler) as only at that time the exact size of object file
can be calculated by summing the size of each section of object file. We
need to know the size of exe/object file because maximum stack available
at run time will be virtual memory size - size of exe. Also no DLLs
will be allowed,
Please let me know your view on this.
Thanks and Best Regards,
Conexant Systems Inc
FC-2&4, Sector 16A,
Tel: 91 120 2512833, Extn @2408
[This looks to me equivalent to the halting problem. That means there are some
special cases you can solve, some of which are quite useful, but in general it's
Return to the
Search the comp.compilers archives again.