• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Method call args order
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Method call args order


  • Subject: Re: Method call args order
  • From: David A Rowland <email@hidden>
  • Date: Mon, 25 Sep 2006 08:46:27 -0700

Title: Re: Method call args order
At 4:12 PM +0100 9/25/06, Paul Walmsley wrote:
I have problems with this function call:

int i=0;
printf("Format %i, %i\n", i++, i++);
The order of evaluation of function arguments is undefined in C++, so there is no guarantee which of the i++ gets evaluated first.  See Item 31 in Sutter & Alexandrescu's 'C++ coding standards'.  This is exactly the example they give that is not guaranteed to work.

That is true also of expressions. The C++ Standard deals with that in section 5 and says "Except where noted, the order of evaluation of operands of individual operators and subexpressions of individual
expressions, and the order in which side effects take place, is unspecified". The && and || operators do "short circuit" evaluation, left argument first. Other than that I think it is up to the compiler writer.

David
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Method call args order
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Method call args order (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Method call args order (From: Paul Walmsley <email@hidden>)

  • Prev by Date: Re: The program "cc1objplus" was terminated unexpectedly.
  • Next by Date: Re: Method call args order
  • Previous by thread: Re: Method call args order
  • Next by thread: Re: Method call args order
  • Index(es):
    • Date
    • Thread