Re: Is there stack associated when a executing an inline function?



On Feb 29, 10:29 am, jacob navia <ja...@xxxxxxxxxx> wrote:
Keith Thompson wrote:
jacob navia <ja...@xxxxxxxxxx> writes:
Mahesh wrote:
       I need to know if stack frames are generated in case of a
inline function execution or
do they execute just like macros?
A stack <frame> will not be generated but any local
storage that the inline function uses will be added to
the local storage of the calling function.

How do you know?  Can you cite the standard to support this claim?

Yes. See the definition of local variables and local storage...

The implementation you describe is certainly plausible, but the
standard says nothing about stack frames, either for inline functions
or for ordinary functions.  

6.2.4.4
An object whose identifier is declared with no linkage and without the
storage-class specifier static has automatic storage duration

Normally, objects with automatic storage duration are implemented
in the stack. Of course, regulars do not accept the fact that 99%
of all machines around use a stack but I really do not care.

Automatic objects are associated with blocks, not function bodies.

There is no requirement that all of the blocks within a function body
must be allocated in a single piece of automatic storage which is
acquired on entry into the function and deallocated on exit. (An
inlined function can be considered to be a block for this purpose).

In principle, blocks can allocate and deallocate individually. That
requires a small overhead, but it would be a smart implementation
strategy for blocks that contain large arrays. Or at least a code-
generation option, if not default behavior.



.



Relevant Pages