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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:16:31+00:00 2026-06-04T16:16:31+00:00

I understand the problems with the classic example of int i=0; foo(i++, i++); but

  • 0

I understand the problems with the classic example of

int i=0;
foo(i++, i++);

but I can’t convince myself of whether the following is valid or invalid

int foo(int& i)
{
   i=42;
   return 99;
}

bar(foo(i), i);

I understand that the order ‘foo(i)’ and ‘i’ are evaluated is undefined, but what exactly does ‘evaluated’ mean? i.e. will the 2nd parameter of bar always be 42, or can the current value of ‘i’ be passed in before foo changes it?

  • 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-04T16:16:32+00:00Added an answer on June 4, 2026 at 4:16 pm

    No it is not guaranteed.
    The order of evaluation of arguments to an function is Unspecified[Ref 1].
    It can be possible that either:

    • foo(i) gets evaluated first or
    • i gets evaluated or
    • any other magical order(in case number of arguments were more than two)

    Unspecified in this context means the implementation is allowed to implement the said feature whichever way they want and it need not be documented.


    [Ref 1]
    C++03 5.2.2 Function call
    Para 8

    The order of evaluation of arguments is unspecified. All side effects of argument expression evaluations take effect before the function is entered. The order of evaluation of the postfix expression and the argument expression list is unspecified.

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

Sidebar

Related Questions

I understand why structs can't contain circular references which lead to logical memory problems,
I'm having problems and I'm not sure I understand the STL documentation. Let's say
I dont understand what would be the problem with the following code. It needs
Can't understand what is a problem here: I have got main.cpp file where I
I've recently started tinkering with ASP.NET MVC, but this question should apply to classic
I am having problems and I don't really understand why. I have a JFrame
As far as I understand the predicates setof/3 and bagof/3 can be used generate
I followed the docs on cap + nginx + unicorn but have some problems
I do not understand the error in compilation. I don't see any syntax problems.
I understand how to use the WITH clause for recursive queries (!!), but I'm

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.