function stack frames may overlap?

Discussion in 'C++' started by Good Guy, Jun 28, 2013.

  1. Good Guy

    Good Guy Guest

    hey there
    regarding following info at this address(http://en.wikipedia.org/wiki/Call_stack#Overlap):

    For some purposes, the stack frame of a subroutine and that of its caller can be considered to overlap, the overlap consisting of the area where the parameters are passed from the caller to the callee. In some environments, the caller pushes each argument onto the stack, thus extending its stack frame, then invokes the callee. In other environments, the caller has a preallocated area at the top of its stack frame to hold the arguments it suppliesto other subroutines it calls. This area is sometimes termed the outgoing arguments area or callout area. Under this approach, the size of the area is calculated by the compiler to be the largest needed by any called subroutine.

    may a C++ compiler ever do that? I think of following case for example assuming it's not inlined and only variables in local scopes of its callers arepassed to this function:

    void bar(int & in){in++;}
    Good Guy, Jun 28, 2013
    #1
    1. Advertising

  2. On Fri, 28 Jun 2013 02:09:56 -0700, Good Guy wrote:

    > hey there
    > regarding following info at this
    > address(http://en.wikipedia.org/wiki/Call_stack#Overlap):
    >
    > For some purposes, the stack frame of a subroutine and that of its
    > caller can be considered to overlap, the overlap consisting of the area
    > where the parameters are passed from the caller to the callee. In some
    > environments, the caller pushes each argument onto the stack, thus
    > extending its stack frame, then invokes the callee. In other
    > environments, the caller has a preallocated area at the top of its stack
    > frame to hold the arguments it supplies to other subroutines it calls.
    > This area is sometimes termed the outgoing arguments area or callout
    > area. Under this approach, the size of the area is calculated by the
    > compiler to be the largest needed by any called subroutine.
    >
    > may a C++ compiler ever do that?


    Yes. The C++ standard does not place any requirements on how function
    arguments are passed around, nor on how local variables are allocated.
    Both described mechanisms (allocating/deallocating stack memory as needed
    and allocating the maximum needed at function entry) are consistent with
    what little the C++ standard states about this.

    > I think of following case for example
    > assuming it's not inlined and only variables in local scopes of its
    > callers are passed to this function:
    >
    > void bar(int & in){in++;}


    What were your concerns with this example?
    Note that it is a common implementation technique to pass reference
    parameters as a pointer that gets automatically dereferenced when used in
    the function.

    Bart v Ingen Schenau
    Bart van Ingen Schenau, Jun 28, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam Iam
    Replies:
    0
    Views:
    444
    Sam Iam
    Jan 31, 2004
  2. Rahmi Acar
    Replies:
    5
    Views:
    421
    Karl Heinz Buchegger
    Jul 28, 2003
  3. Aahz
    Replies:
    0
    Views:
    387
  4. kingchuffalo
    Replies:
    0
    Views:
    865
    kingchuffalo
    Sep 21, 2008
  5. Replies:
    5
    Views:
    344
Loading...

Share This Page