Search code examples
c++cpost-incrementunary-operatorpre-increment

Multiple increment operators in single statement


Possible Duplicate:
Undefined Behavior and Sequence Points

Pleae explain the behaviour of following statements

int b=3;
cout<<b++*++b<<endl;

How will it be calculated?


Solution

  • The behavior here is undefined. See this question

    Relevant standard quote:

    §5/4.1 Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression.

    The most common sequence point is the end of a statement.

    Also worth noting from the standard:

    §5.2.2/8 The order of evaluation of arguments is unspecified.