Jordan Abel wrote On 11/09/06 13:14,:
> 2006-11-09 <1163090289.653296@news1nwk>,
> Eric Sosman wrote:
>[...]
>> There's no such thing as "violating a sequence point."
>>You're probably referring to the rules that require certain
>>operations -- two modifications to the same object, for
>>example
>
>
> or a modification and an access IIRC
>
>
>>-- to be separated by at least one sequence point,
>>but the code snippets above do not break those rules.
Depends on nature of the access. 6.5/2:
Between the previous and next sequence point an
object shall have its stored value modified at
most once by the evaluation of an expression.
Furthermore, the prior value shall be read only
to determine the value to be stored.
I've always found that second sentence troubling, because
it seems to ascribe "purpose" or "intent" to the workings
of the abstract machine. "Only to determine" is hard to
read -- for me, anyhow -- in terms of an implementation
rather than in terms of a programmer or implementor. The
programmer has purposes and does things for reasons, but
the implementation just exhibits the behavior the Standard
describes, without intent and without consiousness.
However, there's a footnote that says `i = ++i + 1' and
`a[i++] = i' are undefined while `i = i + 1' and `a[i] = i'
are allowed. The second example seems to be the one that
illustrates the second sentence: `i' is modified, and its
prior value is used in two different ways. As an operand
of `++', the prior value determines the new value (and the
sub-expression value), and this is allowed. The reference
on the r.h.s., though, is not "for the purpose of" computing
the new value, so it's disallowed. The non-normative footnote
conveys the meaning better (to me) than the normative text.
--