In the above code, the ++ prefix takes precedence over *= , so it starts first. As a result, l is 4 .
UPDATE: This is truly undefined behavior. My guess is that the priority rule was false.
The reason is that l is both an lvalue and an rvalue in *= , as well as in ++ . These two operations are not sequenced. Consequently, l written (and read) twice "without a sequence point" (the old standard formulation), and the behavior is undefined.
As a side element, I assume that your question is related to changes in sequence points in C ++ 0x. C ++ 0x changed the wording regarding “sequence points” to “sequenced before” to make standard definition clear. As far as I know, this does not change the behavior of C ++.
UPDATE 2: It turns out that there is actually a well-defined sequence in accordance with sections 5.17 (1), 5.17 (7) and 5.3.2 (1) of N3126 draft for C ++ 0x . @Johannes Schaub's answer is correct, and documents the sequence of the statement. Of course, the loan should go to his answer.
Håvard S 02 Dec '10 at 15:53 2010-12-02 15:53
source share