Re: Function call evaluation order
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Wed, 22 Mar 2006 21:50:45 -0500
"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
.
- Follow-Ups:
- Re: Function call evaluation order
- From: Tim Roberts
- Re: Function call evaluation order
- References:
- Function call evaluation order
- From: Cheng
- Function call evaluation order
- Prev by Date: Re: /MT and /MD
- Next by Date: How to define a real vector?
- Previous by thread: Function call evaluation order
- Next by thread: Re: Function call evaluation order
- Index(es):
Relevant Pages
|