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