Xref: utzoo alt.folklore.urban:16731 comp.lang.c:40534 alt.folklore.computers:13204 Path: utzoo!utgpu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ncar!gatech!mcnc!rti!mozart!sasrer From: sasrer@unx.sas.com (Rodney Radford) Newsgroups: alt.folklore.urban,comp.lang.c,alt.folklore.computers Subject: Re: Beautiful side-effects! (q = q++) Message-ID: <1991Jun27.141220.9544@unx.sas.com> Date: 27 Jun 91 14:12:20 GMT References: <15520@exodus.Eng.Sun.COM> <1991Jun25.151408.1024@ux1.cso.uiuc.edu> <1991Jun26.154734.14439@dsuvax.uucp> Organization: SAS Institute Inc. Lines: 28 In article <1991Jun26.154734.14439@dsuvax.uucp> rolfe@dsuvax.uucp (Timothy J. Rolfe) writes: >Beautify, beautiful side effect!! > >As it stands, "q = q++;" SHOULD leave q unchanged: evaluating the >right hand side we get a value (q BEFORE the increment). That is >the value that is supposed to go to the left hand side. The question >is WHEN the post-increment is done. ANSII C says the behaviour of the above line is indetermined (ie: implementation dependent), and should be avoided in writing portable C programs (to more that one machine, or more that one compiler, or possibly to different versions of the same compiler...). The reason ANSII could not set a standard on this is that through the years so many different versions of C existed and handled this differently. Also should be avoided statements such as: array[i++] = i; --- or --- function(++k,k,k++) These are just other examples of indeterminate side-effect expressions.... -- Rodney Radford || Computer Graphics/Imaging sasrer@unx.sas.com || SAS Institute, Inc. (919) 677-8000 x7703 || Cary, NC 27513