Order of evaluation

Order of evaluation of any part of any expression, including order of evaluation of function arguments is unspecified (with some exceptions listed below). The compiler can evaluate operands and other subexpressions in any order, and may choose another order when the same expression is evaluated again.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 1885C++11sequencing of the destruction of automaticvariables on function return was not explicitsequencing rules added
CWG 1949C++11“sequenced after” was used but not defined in the C++ standarddefined as the inverseof “sequenced before”
CWG 1953C++11side effects and value computations involving a memorylocation could be unsequenced relative to starting or endingthe lifetime of an object in the same memory locationthe behavior isundefined in this case
CWG 2146C++98the cases involving undefined behaviors did not consider bit-fieldsconsidered

# See also