Re: stack overflow at compile time

henry@spsystems.net (Henry Spencer)
30 Apr 2006 18:37:32 -0400

          From comp.compilers

Related articles
[6 earlier articles]
Re: stack overflow at compile time jvorbrueggen@mediasec.de (=?ISO-8859-1?Q?Jan_Vorbr=FCggen?=) (2006-04-28)
Re: stack overflow at compile time jatin.bhateja@conexant.com (Jatin Bhateja) (2006-04-28)
Re: stack overflow at compile time emailamit@gmail.com (Amit Gupta) (2006-04-29)
Re: stack overflow at compile time bobduff@shell01.TheWorld.com (Robert A Duff) (2006-04-29)
Re: stack overflow at compile time emailamit@gmail.com (Amit Gupta) (2006-04-30)
Re: stack overflow at compile time henry@spsystems.net (2006-04-30)
Re: stack overflow at compile time henry@spsystems.net (2006-04-30)
Re: stack overflow at compile time bobduff@shell01.TheWorld.com (Robert A Duff) (2006-05-01)
Re: stack overflow at compile time gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-05-03)
| List of all articles for this month |

From: henry@spsystems.net (Henry Spencer)
Newsgroups: comp.compilers
Date: 30 Apr 2006 18:37:32 -0400
Organization: SP Systems, Toronto, Canada
References: 06-04-157 06-04-161 06-04-166
Keywords: storage, analysis

Jatin Bhateja <jatin.bhateja@conexant.com> wrote:
>...Now if user is using function pointers in program in that case we
>will be able to tell the maximum stack requirement of the program which
>can be less than the actual because one is not sure which function is
>invoked at run time.


You can handle function pointers -- provided the program doesn't use casts
or unions to obscure what's really going on -- by noting which functions
have their addresses taken. Then a call via a function pointer goes to
one of those functions, and you can treat it like a case statement whose
branches are function calls: the possible stack use is the maximum of all
the possibilities. You may be able to narrow the choice down based on the
type of the particular function pointer, and fancier static analysis can
sometimes add further constraints on what might be called where.


That will handle a lot of the simple cases, e.g., a tree-walk function is
passed a pointer to one of three node-action functions. In complicated
cases, additional problems may appear; for example, if a function whose
address is taken makes a call via a function pointer, this could introduce
recursion (if not ruled out by type constraints etc.).
--
spsystems.net is temporarily off the air; | Henry Spencer
mail to henry at zoo.utoronto.ca instead. | henry@spsystems.net



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.