Hello. > On Fri, 2009-08-28 at 10:29 +0200, Benjamin Monate wrote: >> AFAIU if p==&a then >> a=++(*p) ; >> is the same as >> a=++a; >> which is undefined as it has two effects on "a" between two sequence points. > > The example had p==&p, not p==&a. a=++(*p) doesn't have two effects on > 'a'---it has one on 'a' and one on 'p'. > >> See the answer of John Regher to have the normative reference. > > His email stated that the problem was that 'p' 'is modified and the > prior value is read other than to determine the value to be stored,' one > criterion for undefined behavior. > > -Elnatan >
I was considering the second example sent by Roberto. Here we need to evaluate the following: a = ((*p[0]->next) += 1); in a state where the subexpression *p[0]->next evaluates to p[0]. So the statement above modifies objects 'a' and 'p[0]', which are distinct. Moreover, the *old* value of object 'p[0]' is read (only once) and it is only used to compute the *new* value that has to be stored into object 'p[0]'. So I cannot see the undefined behavior mentioned in C99 6.5-2: ===== 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.70) ===== To my eyes, this is exactly the same as p[0] = p[0] + 1; Am I missing something? Cheers, Enea Zaffanella. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users