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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:34:14+00:00 2026-06-05T14:34:14+00:00

Suppose I have an arbitrary function: void someFunc(int, double, char); and I call someFunc(8,

  • 0

Suppose I have an arbitrary function:

void someFunc(int, double, char); 

and I call someFunc(8, 2.4, 'a');, what actually happens? How does 8, 2.4, and ‘a’ get memory, moved into that memory, and passed into the function? What type of optimizations does the compiler have for situations like these? What if I mix and match parameters, such like someFunc(myIntVar, 2.4, someChar);?

What happens if the function is declared as inline?

  • 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-06-05T14:34:16+00:00Added an answer on June 5, 2026 at 2:34 pm

    It makes no difference that the values are literal or not (unless the function is inlined and then the compiler can optimize some stuff out).

    Usually, parameters are put into registers or the function parameter stack. Regardless of whether they are explicit values or variables.

    Without optimizations, the parameter gets pushed onto the parameter stack. In the first case, the value of x is taken first and put into register eax, then pushed into the parameter stack. foo prints x.

        foo(x);
    00361A75  mov         eax,dword ptr [x] 
    00361A78  push        eax  
    00361A79  call        get_4 (3612B7h) 
    00361A7E  add         esp,4 
        foo(3);
    00361A81  push        3    
    00361A83  call        get_4 (3612B7h) 
    00361A88  add         esp,4 
    

    With optimizations the function is visible to the compiler (in my sample) and the call is skipped altogether:

        foo(x);
    01011000  mov         ecx,dword ptr [__imp_std::cout (101203Ch)] 
    01011006  push        3    
    01011008  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (1012038h)] 
        foo(3);
    0101100E  mov         ecx,dword ptr [__imp_std::cout (101203Ch)] 
    01011014  push        3    
    01011016  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (1012038h)] 
    

    foo is defined as:

    void foo(int x)
    {
       std::cout << x;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a function that does something on an arbitrary container type (C++11):
Suppose I have a large in memory numpy array, I have a function func
Suppose I have an enum with arbitrary increments between contents. Like so: typedef enum
Suppose I have: public class foobar { public int lorem; public int ipsum; }
Suppose you have a subsystem that does some kind of work. It could be
Suppose we have some arbitrary positive number x . Is there a method to
Suppose I have a collection (of arbitrary size) of IQueryable<MyEntity> (all for the same
Suppose a function f() returns a value of arbitrary type, perhaps an object but
Suppose we have an arbitrary graph represented by nodes and pointers like this: class
Suppose I have an arbitrary iterable - for example, a generator that iterates over

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.