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: Sun, 06 May 2012 07:53:08 -0500 Message-ID: <4FA67433.60EC@mindspring.com> Date: Sun, 06 May 2012 08:53:07 -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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 49 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.222.208 X-Trace: sv3-KTHJ2zfvROXeRK+BLPHn0SuYCewW1XG6V8nehmVaGsOK5uca7WXabh7Axh2Ty+bVJSbu27kv8OHyQyX!jdjmSheV4/52BxWWFbTJdBoSFowKmqP0/EfOKeYiEUbnuchSNAV493OvkgckxU6rugaB7OZV0XO6!SXSaelLnVB4= 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: 2304 Xref: csiph.com comp.lang.c:20420 somenath wrote: > > Hi All, > > The following program is crashing. > char s[] ="test"; > char *t=s; > *t = toupper(*t++); > //t++; The comment is interesting because it shows that you thought about doing it the right way. > 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++); No. What is guaranteed, is that the side effects from the evaluation of the arguments in a function call, will be completed *before* the function call. n1570 6.5.2.2 Function calls Constraints 12 EXAMPLE In the function call (*pf[f1()]) (f2(), f3() + f4()) the functions f1, f2, f3, and f4 may be called in any order. All side effects have to be completed before the function pointed to by pf[f1()] is called. Do you have a copy of n1570? 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. -- pete