http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54907



--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> 2012-10-12 15:40:05 UTC ---

I believe this code is well-defined.



There are two objects modified, p and *p.  p is modified by the 

assignment, and C11 6.5.16#3 says "The side effect of updating the stored 

value of the left operand is sequenced after the value computations of the 

left and right operands.".  For postfix increment, which modifies *p, "The 

value computation of the result is sequenced before the side effect of 

updating the stored value of the operand.".  Each object is modified only 

once, so there is no issue of two side effects on the same object being 

unsequenced.  And the value computation of the RHS, using p, is sequenced 

before p is updated by the assignment; furthermore, 5.1.2.3#2 says "Value 

computation for an lvalue expression includes determining the identity of 

the designated object.".  So I don't think either case of undefinedness in 

6.5#2, "If a side effect on a scalar object is unsequenced relative to 

either a different side effect on the same scalar object or a value 

computation using the value of the same scalar object, the behavior is 

undefined.", applies here.

Reply via email to