Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 08 May 2012 05:35:22 -0500 Message-ID: <4FA8F6EC.52A3@mindspring.com> Date: Tue, 08 May 2012 06:35:24 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: pointer arithmetic question. References: <8d75171a-27cf-45ac-b9f4-57427d79b0d6@h4g2000pbe.googlegroups.com> <4FA67433.60EC@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 39 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.156.228.178 X-Trace: sv3-B6OX6V+yP3ojUlgXM8Qi7G0ghmfaJrxil1rlQjLfsfywCUowwzbTZx+jecrbeOPkQQYepeFmlNbCraa!ojrqjqGC9cTAqjY8oXAK1RJpPdsabUj3fdDitj3WwuOyJpqY1lIUI+b2IvDBs5X1SRp99/acr0NK!Sej/IHjcV1g= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2134 Xref: csiph.com comp.lang.c:20497 pete wrote: > > somenath wrote: > > > > Hi All, > > > > The following program is crashing. > > > char s[] ="test"; > > char *t=s; > > > *t = toupper(*t++); > > //t++; > > But how that can happen also ? As post increment operator's side > > effect will be taking effect after the sequence point in this case > > after execution of the code *t = toupper(*t++); > Also, > for the above definition of (t), > the opcode for this expression: (t++) > may or may not be > the same as the opcode for this expression: (++t, t-1). > Whether the side effect takes place before > or after the value of (t++)is determined, > is up to the implementation. That's the old way. In the new standard, there is a sequence point in the value of a postfix increment expression. n1570 6.5.2.4 Postfix increment and decrement operators 2 The value computation of the result is sequenced before the side effect of updating the stored value of the operand. -- pete