------- Comment #11 from igodard at pacbell dot net 2010-08-29 18:24 ------- Note to Nelson, for the record here: There is a disagreement about C++ sequence semantics happening in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45437
The gist is the following code: bool b = false; bool f() { b = true; return false; } b |= f(); The question is whether this is well defined (with b having the value true after the assignment) or undefined. Your proposal states: 5.17p1 (assignment and compound assignment operators): The assignment operator (=) and the compound assignment operators all group right-to-left. All require a modifiable lvalue as their left operand and return an lvalue with the type and value of the left operand after the assignment has taken place an lvalue referring to the left operand. The result in all cases is a bit-field if the left operand is a bit-field. In all cases, the assignment is sequenced after the value computation of the right and left operands, and before the value computation of the assignment expression. With respect to an indeterminately-sequenced function call, the operation of a compound assignment is a single evaluation. [ Note: Therefore, a function call shall not intervene between the lvalue-to-rvalue conversion and the side effect associated with any single compound assignment operator. —end note ] All agree that this governs; the question is what "the value computation of the right and left operands" of the |= assignment means. In one interpretation, it means the rvalue evaluation of b and f(); in this interpretation the ordering of the operand evaluations is undefined and hence the value of b at and after the assignment is also undefined. It is unclear how the assignment receives an lvalue to assign to in this interpretation. In the second interpretation, it means the lvalue evaluation of b and the rvalue evaluation of f(); in this interpretation the lvalue-to-rvalue conversion of b takes place within the assignment, so consequently f() must be evaluated before the conversion takes place. Hence, the assignment receives the (lvalue) b with a well-defined rvalue of true, and the value after the assignment is also well-defined and true. Whichever of these interpretations you had intended, the extent of the disagreement suggests that the proposed wording, while fine for simple assignment, might be clarified for the compound assignment operators. Respectfully, Ivan Godard -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45437