Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6029973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:58:02+00:00 2026-05-23T04:58:02+00:00

In GNU C, The Result is 13. Because the static link is used. Otherwise,

  • 0

In GNU C, The Result is 13. Because the static link is used.
Otherwise, If the dynamic link is used, the result would be 16.

#include <stdio.h>

int h(){
    int x = 1;
    int g(int z){
        return z + x;     <------------------ P
    }
    int f(int y){
        int x = y + 1;
        return g(x * y);   
    }
    return f(3);
}

int main(){
    int a = h();
    printf("%d\n", a);
}

At the P point, Activation Record is


z = 12


x = 4


y = 3


f and pointer to code f


g and pointer to code g


x = 1


h and pointer to code h


a


main and pointer to code main


  1. Is that right?
    However if function g returns, how is it going?
    The Activation for g and Activation for variable z is deleted.
    Then In stack frame, The hole is looked.

  2. The hole really appear?

  3. And According to In-line block, In function h,
    variable x is the most outer block. (It means that function g’ block is nested in variable x’s block)
    next outer block is function g, next function f…
    Then, Do function f’s Static link point to function g’s frame pointer?
    Or function h’s frame pointer?
    What about function g’s Static link?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:58:03+00:00Added an answer on May 23, 2026 at 4:58 am

    At point p, there are 4 activation records on the stack:


    activation record for g:

    • return address to f
    • static link to h activation record
    • z = 12

    activation record for f:

    • x = 4
    • return address to h
    • static link to h activation record
    • y = 3

    activation record for h:

    • x = 1
    • return address to main

    activation record for main:

    • a = undefined
    • return address to OS

    Each activation record for a nested function contains a link to the lexically enclosing activation record (h in both cases here) which is set up when the function is called and the activation record is created. At point p, the code will dereference that link to find the value of x, and looking through such links is the ONLY time a function will ever look at some other function’s activation record.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Look something strange on my mac : $> cat main.c #include <stdio.h> int main(int
What GNU/Linux command-line tool would I use for performing a search and replace on
Consider the following test case: #define _GNU_SOURCE #include <stdio.h> #include <stdarg.h> void test(char **outa,
GNU sed version 4.1.5 seems to fail with International chars. Here is my input
GNU gcc 4.3 partially supports the upcoming c++0x standard: among the implemented features the
GNU Emacs 23.1 I am using iswitchb. However, when I press C-x b I
Gnu Emacs is insisting on indenting my typedef as follows: typedef enum { horizontal,
The GNU Scientific library has a multi-dimensional function minimization framework. However, its caveats explicitly
The GNU/Linux version of cp has a nice --update flag: -u, --update copy only
I just started using GNU Emacs as my text editor and I am concerned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.