2009/4/19 Jason Mancini <jayrus...@hotmail.com>:
>
>> Vincent Lefevre  writes:
>>    while ((*(q++))-- == 0) ;
>
> Is that defined and legal??  Is q incremented before or after *q is 
> decremented?  They are both post operators!
> Jason Mancini

It's defined and legal (so long as q != &q, which might well be
guaranteed by the type system for an incrementable q -- it's late, and
I might be missing a counterexample to that).  The order of the
increment/decrement makes no difference except in the pathological
case where they attempt to change the same object (and in that case,
the behavior is undefined).

Note: the decrement is done to *initial_value_of_q, as q++ evaluates
to a copy of q's initial value.  q could even be incremented before
that, so long as the decrement still applies to *initial_value_of_q.
All of this assumes the absence of "volatile", of course.

-- James

Reply via email to