Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!watserv1!watdragon!rose.waterloo.edu!ccplumb
From: ccplumb@rose.waterloo.edu (Colin Plumb)
Subject: Re: Compiler code (was a flame fest) (now a lesser flame fest)
Message-ID: <1991Apr23.223618.24761@watdragon.waterloo.edu>
Sender: news@watdragon.waterloo.edu (News Owner)
Organization: University of Waterloo
References: <1991Apr17.180342.25312@engin.umich.edu> <91112.093750GHGAQZ4@cc1.kuleuven.ac.be> <3165@dsacg3.dsac.dla.mil>
Date: Tue, 23 Apr 1991 22:36:18 GMT
Lines: 28

ANSI C standard, section 3.3 Expressions:
"Between the previous and next sequence point an object shall have its
stored value modifiedat most once by the evaluation of an expression.
Furthermore, the prior value shall be accessed only to determine the
value to be stored.31"

"31.  This paragraph renders undefined statement expressions such as
	i = ++i + 1;
while allowing
	i = i + 1;"

I'm not going to type in the verbiage about sequence points, but they
are barriers requiring the completion of side effects before them
before access to the variables after.  They occur in a number of
obvious places (between statements, between the left and right sides of
&& || and comma operators, between the evaluation of the arguments and
procedure in a function call, and the call itself, and a few other
places.  In particular, there is no sequence point between the various
arguments to a function, nor is there one between the value-returning
and incrementing features of ++i and i++.

(++i) is equivalent to (i++ + 1)
(i++) is equivalent to (++i - 1)

By both tradition and the ANSI standard, modifying a variable twice in one
expression is undefined.  Don't do it.
-- 
	-Colin
