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 4124006
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:41:05+00:00 2026-05-20T23:41:05+00:00

Appel [App02] very briefly mentions that C ( and presumably C++) provide guarantees regarding

  • 0

Appel [App02] very briefly mentions that C (and presumably C++) provide guarantees regarding the locations of actual parameters in contiguous memory as opposed to registers when the address-of operator is applied to one of formal parameters within the function block.

e.g.

void foo(int a, int b, int c, int d)
{
    int* p = &a;
    for(int k = 0; k < 4; k++)
    {
       std::cout << *p << " ";
       p++;
    }
    std::cout << std::endl;
}

and an invocation such as…

foo(1,2,3,4);

will produce the following output “1 2 3 4”

My question is “How does this interact with calling conventions?”

For example __fastcall on GCC will try place the first two arguments in registers and the remainder on the stack. The two requirements are at odds with each other, is there any way to formally reason about what will happen or is it subject to the capricious nature of implementation defined behaviour?

[App02] Modern Compiler Implementation in Java, Andrew w. Appel, Chapter 6, Page 124

Update: I suppose that this question is answered. I think I was wrong to base the whole question on contiguous memory allocation when what I was looking for (and what the reference speaks of) is the apparent mismatch between the need for parameters being in memory due the use of address-of as opposed to in registers due to calling conventions, maybe that is a question for another day.

Someone on the internet is wrong and sometimes that someone is me.

  • 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-20T23:41:06+00:00Added an answer on May 20, 2026 at 11:41 pm

    First of all your code doesn’t always produce 1, 2, 3, 4. Just check this one: http://ideone.com/ohtt0
    Correct code is at least like this:

    void foo(int a, int b, int c, int d)
    {
        int* p = &a;
        for (int i = 0; i < 4; i++)
        {
            std::cout << *p;
            p++;
        }
    }
    

    So now let’s try with fastcall, here:

    void __attribute__((fastcall)) foo(int a, int b, int c, int d)
    {
        int* p = &a;
        for (int i = 0; i < 4; i++)
        {
            std::cout << *p << " ";
            p++;
        }
    }
    
    int main()
    {
            foo(1,2,3,4);
    }
    

    Result is messy: 1 -1216913420 134514560 134514524

    So I really doubt that something can be guaranteed here.

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

Sidebar

Related Questions

Apple says that this is a good idea for saving memory. What would that
Apple's Documentation mentions that threading the quartzcore rendering of PDF's must be manually handled.
Apple's documentation for UIDocumentInteractionController presentOpenInMenuFromBarButtonItem:animated: method states that If there are no registered apps
Apple is always in the news these days with i this and i that.
I am writing an SQL query as a Javascript string like that: SQLdetail =
I'm a new developper in CRM 2011. I've made that simple code for tests.
Apple says that there is a visibleRect method on the mac ( Source ),
I have the following web service that allows me uploading files: [WebService(Namespace = http://tempuri.org/)]
Apple Http Live Streaming Overview document clearly states that streaming videos exceeding 10 minutes
Apple's Advanced Memory Management doc is pretty well written and precise, but I wonder

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.