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

  • Home
  • SEARCH
  • 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 6980285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:59:46+00:00 2026-05-27T17:59:46+00:00

For the code shown below, If I print the addresses, I get the following.

  • 0

For the code shown below, If I print the addresses, I get the following.

&test_var1 = 0x7fff0067d87c
&barrier (passed argument) = 0x7fff0067d770
&i (passed argument) = 0x7fff0067d77c
&test_var2 = 0x7fff0067d78c

There are two things I don’t understand here. First is that I read that C pushes arguments from right to left, then how &i is greater than &barrier. Knowing that stack grows from a higher address to a lower address, &i should be at a lower address. Moreover, the local variable test_var2 is at even a greater address.

Secondly, one would expect the value of &barrier and &test_var1 to be close together, but no, you see a big difference of 268 bytes. What is the stack holding in between?

Note that I’m using optimization O3. Is this due to that? Maybe the compiler has played some tricks here? I use volatile to make sure every variable is on the stack here and not cached in some register.

void some_func()
{
.........
{
  volatile int test_var1 = 0;
}
call_func( i, &barrier );
........
}

void call_func( volatile int i, volatile pthread_barrier* barrier )
{
 volatile int test_var2 = 0;
 ........
}
  • 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-27T17:59:47+00:00Added an answer on May 27, 2026 at 5:59 pm

    On x86 the stack (used when f() calls g()) grows downward.

    Anyhow the way the compiler arranges the var/s for a certain call is implementation dependend.

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

Sidebar

Related Questions

In the code shown below, how to get the values of multiselect box in
Okay, so I've got the following code shown below to create a dialog using
I wrote a code as shown below to print stack trace. I am using
I have a python psp page code is shown below. Currently it only prints
In the code shown below, I need to manipulate the time var in python
I have noticed that my geocoder is inconsistent in the code shown below because
How to drag and drop the dynamically created controls my code is shown below
Background: I have a WPF UserControl (MainControl - not shown in code below) that
My code shown below will successfully return an array of values using print_r. How
I am creating a winsock UDP program. code i am using is shown below.

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.