Re: Function call evaluation order



"Cheng" <chengwuchew@xxxxxxxxxxx> wrote in message
news:u8X%23alhTGHA.4340@xxxxxxxxxxxxxxxxxxxx
I need help to explain the behavior with the code below. I would
like to chain up function call into a single line, while the order of
the function call is correct, I cannot be certain with order the
expression within the function call is evaluated.

Woud it be better, then, to write all the function call into seperate
lines?

s.assign(data[i++]).append(data[i++]).append(data[i++]);

Not only would it be better - you must do so. The statement shown above
exhibits undefined behavior. There exists a possible legal order of
execution of various subexpressions that results in the variable 'i'
being modified more than once between sequence points.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Function call evaluation order
    ... like to chain up function call into a single line, ... execution of various subexpressions that results in the variable 'i' ... being modified more than once between sequence points. ... I mean, I shudder in horror at that line of code, but I thought a ...
    (microsoft.public.vc.language)
  • Re: Part 1 (of 3): What are major aspects of evolutionary theory?
    ... and one sequence was deleted in the ... along a chain of adjacent nodes along a path in a tree. ... If a really long immigration occurs from known source, ... we may presume that to be a duplication event we're observing. ...
    (talk.origins)
  • Re: flight of rooms
    ... To me "suite" suggests a cluster of rooms which do not necessarily form a sequence. ... Thinking of a word roughly synonymous with "sequence" I thought of "chain". ... Blue rooms, white rooms, yellow, green and red, halls for the nobility, halls for the Guardsmen, halls for the diplomats, they stretched ahead of us, gorgeous, gilded, cold, uncomfortable. ...
    (alt.usage.english)
  • Re: Firing Sequential Ignitors with Just One Switch?
    ... and the first ignitor in the chain is lit ... counter will then ignite its rocket. ... simply by setting them to the same sequence number. ...
    (sci.electronics.basics)
  • Re: Difficult problem! Help!!
    ... I thought may be using invoke to break the 'chain' so that the function that ... >> started the whole sequence, is destroyed (this is possible because there ... >> the calling method which started the whole thing. ... >> Tomer. ...
    (microsoft.public.dotnet.framework.compactframework)