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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:44:58+00:00 2026-06-14T06:44:58+00:00

I know the order that function parameters are evaluated is unspecified in C++, see

  • 0

I know the order that function parameters are evaluated is unspecified in C++, see below,

// The simple obvious one.

callFunc(getA(),getB());

Can be equivalent to this:

int a = getA();
int b = getB();
callFunc(a,b);
Or this:

int b = getB();
int a = getA();
callFunc(a,b);

This is perfect fine & I think most ppl know this.

But I have tried VC10, gcc 4.72 and they all evaluate b first (from right to left), meaning b got pushed into stack frame first then a.

I am just wondering which c++ compiler should I try to make the code above to evalute a first ?
So a got pushed to stack before b.

Thanks

  • 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-14T06:44:59+00:00Added an answer on June 14, 2026 at 6:44 am

    The parameter evaluation order substantially depends from the calling convention used for calling the given function – if parameters are pushed on the stack RTL it’s usually more convenient to elaborate the rightmost parameters first.

    According to this table, on x86 the only calling convention available on IA32 with LTR parameter order on the stack is fastcall on Borland, that however passes the first three integer/pointer parameters in registers. So you should write a function that takes more than three integers, mark it as fastcall and compile it with a Borland compiler; in that case probably the other parameters besides the first three should be evaluated in LTR order.

    Going on other platforms probably you’ll find other calling conventions with LTR parameter passing (and so probably LTR parameters evaluation).

    Notice that the parameter passing order <=> parameter evaluation order are logically bound, but if for some reason the compiler finds that it’s better to evaluate some parameter before the others there’s nothing in the standard preventing it to do so.

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

Sidebar

Related Questions

It's well-known that the order of evaluation of a function's arguments in unspecified and
I know that C++ doesn't specify the order in which parameters are passed to
I know that in order to download a cookie associated with an account using
I know that in order to programmatically add my own taxonomy to a node
I know that in order for me to force the app to be in
1) I know there are lots of web sites that describe in what order
I am writing a function that returns a table. There are two parameters that
I would like to create a function that finds the parameters p and q
I totally understand that in order to learn javascript I need to know how
I never really know what order is the best installation or if it even

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.